def test_read(self): """ Asserts that read runs when plugin is loaded """ collectd_plugin.PLUGIN = MagicMock() collectd_plugin.PLUGIN.read = MagicMock() collectd_plugin.read() self.assertTrue(collectd_plugin.PLUGIN.read.called)
def test_read_no_plugin(self, mock_read): """ Asserts that read does not run when plugin is not loaded Args: :param mock_read a patched method from a :mod:`CollectdPlugin`. """ collectd_plugin.read() self.assertFalse(mock_read.called)
def test_read(self): """ Asserts that read runs when plugin is loaded """ fake_config = MagicMock() collectd_plugin.INSTANCES = [fake_config] fake_config.read = MagicMock() collectd_plugin.read() self.assertIsNotNone(collectd_plugin.CONFIGS) self.assertTrue(fake_config.read.called) collectd_plugin.INSTANCES = []