| |
@@ -22,19 +22,16 @@
|
| |
import mock
|
| |
import fedmsg.config
|
| |
|
| |
- from mock import patch
|
| |
- from freshmaker.consumer import FreshmakerConsumer
|
| |
-
|
| |
-
|
| |
- @patch("freshmaker.consumer.get_global_consumer")
|
| |
- class TestPoller(unittest.TestCase):
|
| |
+ import freshmaker
|
| |
|
| |
+ class ConsumerTest(unittest.TestCase):
|
| |
def setUp(self):
|
| |
pass
|
| |
|
| |
def tearDown(self):
|
| |
pass
|
| |
|
| |
+ @mock.patch("freshmaker.consumer.get_global_consumer")
|
| |
def test_consumer_processing_message(self, global_consumer):
|
| |
"""
|
| |
Tests that consumer parses the message, forwards the event
|
| |
@@ -43,7 +40,7 @@
|
| |
"""
|
| |
hub = mock.MagicMock()
|
| |
hub.config = fedmsg.config.load_config()
|
| |
- consumer = FreshmakerConsumer(hub)
|
| |
+ consumer = freshmaker.consumer.FreshmakerConsumer(hub)
|
| |
global_consumer.return_value = consumer
|
| |
|
| |
msg = {'body': {
|
| |
@@ -61,3 +58,17 @@
|
| |
|
| |
event = consumer.incoming.get()
|
| |
self.assertEqual(event.msg_id, "ModuleBuilt handled")
|
| |
+
|
| |
+ @mock.patch("freshmaker.consumer.get_global_consumer")
|
| |
+ def test_consumer_subscribe_topic(self, global_consumer):
|
| |
+ """
|
| |
+ Tests subscribe topics of consumer.
|
| |
+ """
|
| |
+ hub = mock.MagicMock()
|
| |
+ hub.config = fedmsg.config.load_config()
|
| |
+ consumer = freshmaker.consumer.FreshmakerConsumer(hub)
|
| |
+ global_consumer.return_value = consumer
|
| |
+ topics = freshmaker.events.BaseEvent.get_parsed_topics()
|
| |
+ callback = consumer._consume_json if consumer.jsonify else consumer.consume
|
| |
+ for topic in topics:
|
| |
+ self.assertIn(mock.call(topic, callback), hub.subscribe.call_args_list)
|
| |
freshmaker consumer's topic is an instance attribute, if it is not
set prior to call parent's (which is FedmsgConsumer) init(),
the consumer will not subscribe to its topics while instantiating.