Files
orisys_arm/station/test/test_subscriptions.py
T
2026-10-16 17:27:30 +08:00

23 lines
1.2 KiB
Python

from unittest import TestCase
from station.subscriptions import SubscriptionSet, demanded_streams
class SubscriptionsTest(TestCase):
def test_switches_release_unused_real_sim_depth(self):
cams=[{'id':'left'},{'id':'right'},{'id':'sim_wrist'},{'id':'overhead'}]
subscriptions=SubscriptionSet();created=[];destroyed=[]
def create(key): created.append(key);return key
def sync(preview=(),jpeg=()):
subscriptions.sync(demanded_streams(cams,preview,jpeg),create,destroyed.append)
sync(['left_color','overhead_color'])
self.assertEqual(set(created),{'left_color','overhead_color'})
sync(['right_depth','overhead_depth'])
self.assertEqual(set(subscriptions.items),{'right_depth','overhead_depth'})
self.assertEqual(set(destroyed),{'left_color','overhead_color'})
sync([],['left_color'])
self.assertEqual(set(subscriptions.items),{'left_color'})
sync(['sim_wrist_color'])
self.assertEqual(set(subscriptions.items),{'sim_wrist_color'})
sync();self.assertEqual(subscriptions.items,{})
sync(['unknown_color']);self.assertEqual(subscriptions.items,{})