Remove initialisation warning from the boiler
This commit is contained in:
1 parent
9a58cc5296
commit
d79bba15b0
2 files changed
+30
-5
No files matched your search
@@ -467,16 +467,31 @@ class WatchdogTests(unittest.TestCase):
|
||||
a = object.__new__(BoilerWatchdog)
|
||||
a.base, a.mqtt_namespace, a.timeout = 'appdaemon/test', 'mqtt', 180
|
||||
a.last_heartbeat, a.fault = None, False
|
||||
a.waiting_since, a.warned = 1000, False
|
||||
a.call_service, a.log = Mock(), Mock()
|
||||
a.initialize_logger_interface(a, ascii_encode=False)
|
||||
return a
|
||||
|
||||
def test_missing_heartbeat_publishes_offline_once(self):
|
||||
a = self.app()
|
||||
a._check()
|
||||
a._check()
|
||||
with patch('boilerwatchdog.time.monotonic', return_value=1000):
|
||||
a._check()
|
||||
a._check()
|
||||
a.call_service.assert_called_once_with('mqtt/publish', namespace='mqtt',
|
||||
topic=a.base + '/availability', payload='offline', qos=0, retain=True)
|
||||
a.log.assert_not_called()
|
||||
a._mqtt_event('', {'topic': a.base + '/heartbeat'}, {})
|
||||
a.log.assert_not_called()
|
||||
|
||||
def test_first_heartbeat_missing_beyond_timeout_warns_once(self):
|
||||
a = self.app()
|
||||
with patch('boilerwatchdog.time.monotonic', return_value=1000):
|
||||
a._check()
|
||||
with patch('boilerwatchdog.time.monotonic', return_value=1180):
|
||||
a._check()
|
||||
a._check()
|
||||
self.assertEqual(a.log.call_count, 1)
|
||||
self.assertEqual(a.log.call_args.kwargs['level'], 'WARNING')
|
||||
|
||||
def test_timeout_and_recovery_do_not_override_sensor_availability(self):
|
||||
a = self.app()
|
||||
@@ -488,6 +503,7 @@ class WatchdogTests(unittest.TestCase):
|
||||
with patch('boilerwatchdog.time.monotonic', return_value=1180):
|
||||
a._check()
|
||||
self.assertTrue(a.fault)
|
||||
self.assertTrue(a.warned)
|
||||
a.call_service.reset_mock()
|
||||
a._mqtt_event('', {'topic': a.base + '/heartbeat'}, {})
|
||||
self.assertFalse(a.fault)
|
||||
@@ -500,6 +516,7 @@ class WatchdogTests(unittest.TestCase):
|
||||
self.assertIsNone(a.last_heartbeat)
|
||||
self.assertTrue(a.fault)
|
||||
self.assertEqual(a.call_service.call_args.kwargs['payload'], 'offline')
|
||||
a.log.assert_not_called()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in new issue
Block a user