예제 #1
0
 def test_dropped_queue(self):
     with pubsub.subscribe() as event_source:
         pubsub.publish("data")
         self.assertEqual(1, event_source.qsize())
     with pubsub.subscribe() as event_source:
         self.assertEqual(0, event_source.qsize())
         try:
             data = event_source.get(False)
             assert False, "Should not have seen data %s" % (data, )
         except Queue.Empty:
             assert True
예제 #2
0
 def test_named_mismatch_publish(self):
     with pubsub.subscribe("queuename") as event_source:
         pubsub.publish("data")
         try:
             data = event_source.get(False)
             assert False, "Should not have received data %s" % (data, )
         except Queue.Empty:
             assert True
예제 #3
0
 def test_publish_subscriptions(self):
     device = drivers.FakeLight(name="test", label="Test")
     with pubsub.subscribe() as event_source:
         self.assertEqual(0, event_source.qsize())
         device.set_state("ON")
         self.assertEqual(1, event_source.qsize())
         event = event_source.get(False)
         self.assertEqual(device, event['device'])
         self.assertEqual("ON", event['state'])
예제 #4
0
 def test_fan_speed_firsttime(self):
     with pubsub.subscribe() as event_source:
         fan = drivers.FakeFan(name="test", label="Test")
         fan.subdevices['speed'].set_state("2")
         self.assertEqual("ON", fan.get_state())
         self.assertEqual("ON", fan.subdevices['power'].get_state())
         self.assertEqual("2", fan.subdevices['speed'].get_state())
         self.assertEqual("2", fan.subdevices['command'].get_state())
         # collect events
         events = events_summary(event_source)
     self.assertEqual("ON", events['fans/test'])
     self.assertEqual("ON", events['fans/test/power'])
     self.assertEqual("2", events['fans/test/speed'])
     self.assertEqual("2", events['fans/test/command'])
예제 #5
0
 def test_named_publish(self):
     with pubsub.subscribe("queuename") as event_source:
         pubsub.publish("data", topic="queuename")
         self.assertEqual("data", event_source.get(False))
예제 #6
0
 def test_late_publish(self):
     with pubsub.subscribe("queuename") as event_source:
         self.assertEqual(0, event_source.qsize())
     pubsub.publish("data", topic="queuename")
     with pubsub.subscribe("queuename") as event_source:
         self.assertEqual(0, event_source.qsize())
예제 #7
0
 def test_simple_publish(self):
     with pubsub.subscribe() as event_source:
         pubsub.publish("data")
         self.assertEqual("data", event_source.get(False))
예제 #8
0
 def test_empty_subscribe(self):
     with pubsub.subscribe() as event_source:
         assert True