mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Improve smartprotocol error handling and retries (#578)
* Improve smartprotocol error handling and retries * Update after review * Enum to IntEnum and SLEEP_SECONDS_AFTER_TIMEOUT
This commit is contained in:
@@ -315,11 +315,11 @@ class FakeSmartTransport(BaseTransport):
|
||||
method = request_dict["method"]
|
||||
params = request_dict["params"]
|
||||
if method == "component_nego" or method[:4] == "get_":
|
||||
return {"result": self.info[method]}
|
||||
return {"result": self.info[method], "error_code": 0}
|
||||
elif method[:4] == "set_":
|
||||
target_method = f"get_{method[4:]}"
|
||||
self.info[target_method].update(params)
|
||||
return {"result": ""}
|
||||
return {"error_code": 0}
|
||||
|
||||
async def close(self) -> None:
|
||||
pass
|
||||
|
@@ -86,7 +86,7 @@ async def test_protocol_retry_recoverable_error(
|
||||
async def test_protocol_reconnect(mocker, retry_count, protocol_class, transport_class):
|
||||
host = "127.0.0.1"
|
||||
remaining = retry_count
|
||||
mock_response = {"result": {"great": "success"}}
|
||||
mock_response = {"result": {"great": "success"}, "error_code": 0}
|
||||
|
||||
def _fail_one_less_than_retry_count(*_, **__):
|
||||
nonlocal remaining
|
||||
|
Reference in New Issue
Block a user