From 9be457028e7cfb225c1ec4980e1172ba4b13f1ad Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Mon, 9 Dec 2024 22:19:38 +0000 Subject: [PATCH] harden tests - fix schema bug --- src/evohomeasync2/schemas/account.py | 2 +- tests/tests_rf/test_v2_urls_auth.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/evohomeasync2/schemas/account.py b/src/evohomeasync2/schemas/account.py index d93ca3a9..a9aaa5e9 100644 --- a/src/evohomeasync2/schemas/account.py +++ b/src/evohomeasync2/schemas/account.py @@ -116,7 +116,7 @@ def factory_status_response(fnc: Callable[[str], str] = noop) -> vol.Schema: entry_schema = vol.Schema( { - vol.Required("error"): str, + vol.Required("code"): str, vol.Required("message"): str, }, extra=vol.PREVENT_EXTRA, diff --git a/tests/tests_rf/test_v2_urls_auth.py b/tests/tests_rf/test_v2_urls_auth.py index 24bebe54..40ed79ef 100644 --- a/tests/tests_rf/test_v2_urls_auth.py +++ b/tests/tests_rf/test_v2_urls_auth.py @@ -67,7 +67,7 @@ async def handle_too_many_requests(rsp: aiohttp.ClientResponse) -> None: """ assert response["error"] == "attempt_limit_exceeded" - assert TCC_ERROR_RESPONSE(response), response + TCC_ERROR_RESPONSE(response) pytest.skip("Too many requests") @@ -101,7 +101,7 @@ async def test_url_auth_bad1( # invalid/unknown credentials """ assert response["error"] == "invalid_grant" - assert TCC_ERROR_RESPONSE(response), response + TCC_ERROR_RESPONSE(response) @pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="requires vendor's webserver") @@ -137,7 +137,7 @@ async def test_url_auth_bad2( # invalid/expired access token assert isinstance(response, list) # mypy hint assert response[0]["code"] == "Unauthorized" - assert TCC_STATUS_RESPONSE(response), response + TCC_STATUS_RESPONSE(response) @pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="requires vendor's webserver") @@ -171,7 +171,7 @@ async def test_url_auth_bad3( # invalid/expired refresh token """ assert response["error"] == "invalid_grant" - assert TCC_ERROR_RESPONSE(response), response + TCC_ERROR_RESPONSE(response) @pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="requires vendor's webserver") @@ -209,7 +209,7 @@ async def test_url_auth_good( """ assert user_auth["expires_in"] <= 1800 # noqa: PLR2004 - assert TCC_POST_OAUTH_TOKEN(user_auth), user_auth + TCC_POST_OAUTH_TOKEN(user_auth) # ################################################################################# @@ -245,7 +245,7 @@ async def test_url_auth_good( """ assert response["username"] == credentials[0] - assert TCC_GET_USR_ACCOUNT(response), response + TCC_GET_USR_ACCOUNT(response) # ################################################################################# @@ -266,7 +266,7 @@ async def test_url_auth_good( assert rsp.status == HTTPStatus.OK # 200 - user_auth = await rsp.json() + user_auth = await rsp.json() # TODO: add TypedDict # the expected response for good refresh tokens """ @@ -280,4 +280,4 @@ async def test_url_auth_good( """ assert user_auth["expires_in"] <= 1800 # noqa: PLR2004 - assert TCC_POST_OAUTH_TOKEN(user_auth), user_auth + TCC_POST_OAUTH_TOKEN(user_auth)