|
|
@@ -169,11 +169,13 @@ class TestDevice(IsolatedAsyncioTestCase):
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
+ Exception("Error"),
|
|
|
+ Exception("Error"),
|
|
|
]
|
|
|
self.subject.refresh()
|
|
|
|
|
|
self.subject._api.set_version.assert_has_calls(
|
|
|
- [call(3.1), call(3.3), call(3.1)]
|
|
|
+ [call(3.1), call(3.2), call(3.4), call(3.3), call(3.1)]
|
|
|
)
|
|
|
|
|
|
def test_api_protocol_version_is_stable_once_successful(self):
|
|
|
@@ -181,19 +183,30 @@ class TestDevice(IsolatedAsyncioTestCase):
|
|
|
self.subject._api.set_version.reset_mock()
|
|
|
|
|
|
self.subject._api.status.side_effect = [
|
|
|
+ Exception("Error"),
|
|
|
+ Exception("Error"),
|
|
|
+ Exception("Error"),
|
|
|
{"dps": {"1": False}},
|
|
|
+ {"dps": {"1": False}},
|
|
|
+ Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
Exception("Error"),
|
|
|
+ {"dps": {"1": False}},
|
|
|
]
|
|
|
self.subject.refresh()
|
|
|
+ self.assertEqual(self.subject._api_protocol_version_index, 3)
|
|
|
self.subject.refresh()
|
|
|
+ self.assertEqual(self.subject._api_protocol_version_index, 3)
|
|
|
self.subject.refresh()
|
|
|
+ self.assertEqual(self.subject._api_protocol_version_index, 3)
|
|
|
|
|
|
- self.subject._api.set_version.assert_has_calls([call(3.1), call(3.3)])
|
|
|
+ self.subject._api.set_version.assert_has_calls(
|
|
|
+ [call(3.1), call(3.2), call(3.4)]
|
|
|
+ )
|
|
|
|
|
|
def test_reset_cached_state_clears_cached_state_and_pending_updates(self):
|
|
|
self.subject._cached_state = {"1": True, "updated_at": time()}
|