def test_should_publishing_without_collecting_events_on_queue(self): publisher = OutputPublisher() consumer = TerminalOutputConsumer() publisher.add_consumer(consumer) event = prepare_event() publisher.publish(event=event) self.assertTrue(consumer._received) self.assertEqual(0, publisher.event_queue.qsize()) self.assertEqual(1, len(publisher.consumers))
def test_should_collect_event_and_publish_it_to_each_consumer(self): publisher = OutputPublisher() consumer = TerminalOutputConsumer() publisher.add_consumer(consumer) event = prepare_event() publisher.collect(event) publisher.publish() self.assertTrue(consumer._received) self.assertEqual(0, publisher.event_queue.qsize()) self.assertEqual(1, len(publisher.consumers))
def test_should_consume_one_event_successfully(self): out = OutputPublisher() out.collect(prepare_event()) consumed = out.publish() self.assertIsNotNone(consumed) self.assertIsNotNone(consumed.timestamp) self.assertEqual(0, out.event_queue.qsize())