def setUp(self, allowed_names=None): if not allowed_names: allowed_names = [] config = get_collector_config('LMSensorsCollector', { 'allowed_names': allowed_names, 'interval': 1 }) self.collector = LMSensorsCollector(config, None)
class TestLMSensorsCollector(CollectorTestCase): def setUp(self): config = get_collector_config('LMSensorsCollector', {}) self.collector = LMSensorsCollector(config, None) def test_import(self): self.assertTrue(LMSensorsCollector) @patch.object(Collector, 'publish') def test_simple_sensor(self, publish_mock): feature = FeatureMock('Core 0', 10) chip = ChipMock("coretemp-isa-0000", [feature]) patch_detected_chips_iter = patch('sensors.iter_detected_chips', return_value=[chip]) patch_detected_chips_iter.start() self.collector.collect() patch_detected_chips_iter.stop() self.assertPublished(publish_mock, 'coretemp-isa-0000.Core-0', 10) @patch.object(Collector, 'publish') def test_empty_sensor(self, publish_mock): feature = FeatureMock('Core 0') chip = ChipMock('coretemp-isa-0000', [feature]) patch_detected_chips_iter = patch('sensors.iter_detected_chips', return_value=[chip]) patch_detected_chips_iter.start() self.collector.collect() patch_detected_chips_iter.stop() self.assertUnpublished(publish_mock, 'coretemp-isa-0000.Core-0', None) @patch.object(Collector, 'publish') def test_empty_zero_sensor(self, publish_mock): self.collector.config['send_zero'] = True feature = FeatureMock('Core 0') chip = ChipMock('coretemp-isa-0000', [feature]) patch_detected_chips_iter = patch('sensors.iter_detected_chips', return_value=[chip]) patch_detected_chips_iter.start() self.collector.collect() patch_detected_chips_iter.stop() self.assertPublished(publish_mock, 'coretemp-isa-0000.Core-0', 0)
def setUp(self): config = get_collector_config('LMSensorsCollector', {}) self.collector = LMSensorsCollector(config, None)