class TestCarbonCollector(CollectorTestCase): def setUp(self): config = get_collector_config('CarbonCollector', { 'exclude' : ['config'], 'gauge' : ['statistics.pool', 'statistics.active'], }) self.collector = CarbonCollector(config, None) def test_import(self): self.assertTrue(CarbonCollector) @patch.object(Collector, 'publish') def test_should_work_with_example(self, publish): global PRE, NOW mock = Mock(self.collector.entries) self.collector.entries = mock mock.return_value = NOW self.collector._predata = PRE self.collector.collect() assert len(publish.call_args_list) @patch.object(Collector, 'publish') def test_reset_monitoring_data(self, publish): pre = { "module": { "NSMTPHandler": { "command": { "elapsed": "2000", "exec": "1000" }}} } now = { "module": { "NSMTPHandler": { "command": { "elapsed": "0", "exec": "0" }}} } mock = Mock(self.collector.entries) self.collector.entries = mock mock.return_value = now self.collector._predata = pre self.collector.collect() assert not publish.called
def setUp(self): config = get_collector_config('CarbonCollector', { 'exclude' : ['config'], 'gauge' : ['statistics.pool', 'statistics.active'], }) self.collector = CarbonCollector(config, None)