Пример #1
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
Пример #2
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
Пример #3
0
 def _set(self, state):
     """ Saves the given state to persistence """
     persistence.set(self._state_path(), state)
     pubsub.publish({'device': self, 'state': state})
Пример #4
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))
Пример #5
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())
Пример #6
0
 def test_simple_publish(self):
     with pubsub.subscribe() as event_source:
         pubsub.publish("data")
         self.assertEqual("data", event_source.get(False))
Пример #7
0
 def test_empty_publish(self):
     pubsub.publish("Data")