Skip to content

Commit 11882cc

Browse files
committed
Merge branch 'fw-13-4'
2 parents dd4069a + f54d61d commit 11882cc

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

recuair_cli/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ async def post_request(client: httpx.AsyncClient, device: str, data: dict[str, A
149149
except httpx.HTTPError as error:
150150
_LOGGER.debug("Error encountered: %s", error)
151151
raise RecuairError(f"Error from device {device}: {error}") from error
152-
if response.status_code != HTTPStatus.MOVED_PERMANENTLY:
152+
# MOVED_PERMANENTLY was returned by firmware 12 (end of 2023).
153+
if response.status_code not in (HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.SEE_OTHER):
153154
raise RecuairError(f"Unknown error from device {device}, status code {response.status_code}")
154155
# XXX: When invalid request is send, Recuair returns status page :-/
155156
_LOGGER.debug("Response [%s]: %s", response, response.text)

recuair_cli/tests/test_main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from http import HTTPStatus
12
from pathlib import Path
23
from unittest import IsolatedAsyncioTestCase, TestCase
34
from unittest.mock import call, patch
@@ -83,7 +84,15 @@ async def test_error(self):
8384
class PostRequestTest(IsolatedAsyncioTestCase):
8485
async def test(self):
8586
with respx.mock() as rsps:
86-
rsps.post("http://example/", data={"answer": "42"}).mock(Response(301))
87+
rsps.post("http://example/", data={"answer": "42"}).mock(Response(HTTPStatus.SEE_OTHER))
88+
89+
async with httpx.AsyncClient() as client:
90+
await post_request(client, "example", {"answer": "42"})
91+
92+
async def test_fw_12(self):
93+
# Test post to firmware 12
94+
with respx.mock() as rsps:
95+
rsps.post("http://example/", data={"answer": "42"}).mock(Response(HTTPStatus.MOVED_PERMANENTLY))
8796

8897
async with httpx.AsyncClient() as client:
8998
await post_request(client, "example", {"answer": "42"})

0 commit comments

Comments
 (0)