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
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
def _set(self, state): """ Saves the given state to persistence """ persistence.set(self._state_path(), state) pubsub.publish({'device': self, 'state': state})
def test_named_publish(self): with pubsub.subscribe("queuename") as event_source: pubsub.publish("data", topic="queuename") self.assertEqual("data", event_source.get(False))
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())
def test_simple_publish(self): with pubsub.subscribe() as event_source: pubsub.publish("data") self.assertEqual("data", event_source.get(False))
def test_empty_publish(self): pubsub.publish("Data")