def before(self): """ Called before every test. """ self.bus = mock.MagicMock() self.store_kwargs = {} self.plugin = Plugin(self.bus, {}, self.store_kwargs)
def before(self): """ Called before every test. """ self.bus = mock.MagicMock() self.plugin = Plugin(self.bus, {})
class Test_InvestigatorPlugin(TestCase): """ Tests for the InvestigatorPlugin class. """ #: Topics that should be registered topics = ('investigator-is-alive', ) def before(self): """ Called before every test. """ self.bus = mock.MagicMock() self.plugin = Plugin(self.bus, {}) def after(self): """ Called after every test. """ self.bus = None self.plugin = None def test_investigator_plugin_creation(self): """ Verify that the creation of the plugin works as it should. """ # The processes should not have started yet self.assertFalse(self.plugin.is_alive()) # There should be bus subscribed topics for topic in self.topics: self.bus.subscribe.assert_any_call(topic, mock.ANY) def test_investigator_plugin_start(self): """ Verify start() starts the background process. """ self.assertFalse(self.plugin.is_alive()) self.plugin.start() self.assertTrue(self.plugin.is_alive()) self.plugin.stop() def test_investigator_plugin_stop(self): """ Verify stop() unsubscribes topics. """ self.plugin.start() self.plugin.stop() # unsubscribe should be called a specific number of times self.assertEquals(len(self.topics), self.bus.unsubscribe.call_count) # Each unsubscription should have it's own call # to deregister a callback for topic in self.topics: self.bus.unsubscribe.assert_any_call(topic, mock.ANY)
def before(self): """ Called before every test. """ self.bus = mock.MagicMock() self.plugin = Plugin(self.bus)
class Test_InvestigatorPlugin(TestCase): """ Tests for the InvestigatorPlugin class. """ #: Topics that should be registered topics = ('investigator-is-alive', 'investigator-is-pending', 'investigator-submit') def before(self): """ Called before every test. """ self.bus = mock.MagicMock() self.plugin = Plugin(self.bus) def after(self): """ Called after every test. """ self.bus = None self.plugin = None def test_investigator_plugin_creation(self): """ Verify that the creation of the plugin works as it should. """ # The processes should not have started yet self.assertFalse(self.plugin.is_alive()) def test_investigator_plugin_start(self): """ Verify start() starts the background process. """ self.assertFalse(self.plugin.is_alive()) self.plugin.start() # There should be bus subscribed topics for topic in self.topics: self.bus.subscribe.assert_any_call(topic, mock.ANY) self.assertTrue(self.plugin.is_alive()) self.plugin.stop() def test_investigator_plugin_stop(self): """ Verify stop() unsubscribes topics. """ self.plugin.start() self.plugin.stop() # unsubscribe should be called a specific number of times self.assertEquals(len(self.topics), self.bus.unsubscribe.call_count) # Each unsubscription should have it's own call # to deregister a callback for topic in self.topics: self.bus.unsubscribe.assert_any_call(topic, mock.ANY)