Ver Fonte

Update tests for additional protocol versions 3.2 and 3.4

Update to ensure that protocol stability test actually checks the stability.
Now that connection limit has been updated and tinytuya 1.7.0 is being used, it really does seem more stable than earlier versions.
Jason Rumney há 3 anos atrás
pai
commit
1e9b5c198e
1 ficheiros alterados com 15 adições e 2 exclusões
  1. 15 2
      tests/test_device.py

+ 15 - 2
tests/test_device.py

@@ -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()}