Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ariston/ariston_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def __request(

if len(response.content) > 0:
json = response.json()
_LOGGER.debug("Response %s", json)
_LOGGER.debug("Response received")
return json

return None
Expand Down Expand Up @@ -1560,7 +1560,7 @@ async def __async_request(

if response.content_length and response.content_length > 0:
json = await response.json()
_LOGGER.debug("Response %s", json)
_LOGGER.debug("Response received")
return json

return None
Expand Down
24 changes: 14 additions & 10 deletions tests/test_ariston_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ def test_login_token_is_sent_with_followup_request(self):
FakeResponse([{"gw": "gateway-1"}]),
]

with patch(
"ariston.ariston_api.requests.request", side_effect=responses
) as request:
self.assertTrue(api.connect())
devices = api.get_detailed_devices()
with self.assertLogs("ariston.ariston_api", level="DEBUG") as logs:
with patch(
"ariston.ariston_api.requests.request", side_effect=responses
) as request:
self.assertTrue(api.connect())
devices = api.get_detailed_devices()

self.assertEqual(devices, [{"gw": "gateway-1"}])
self.assertNotIn("session-token", "\n".join(logs.output))
login_call, devices_call = request.call_args_list
# requests expects seconds: a regression to milliseconds (30000) would
# let a hung connection block the caller for hours.
Expand Down Expand Up @@ -126,11 +128,12 @@ async def connect_and_discover():
self.assertTrue(await api.async_connect())
return await api.async_get_detailed_devices()

with patch(
"ariston.ariston_api.aiohttp.ClientSession",
side_effect=[login_session, devices_session],
) as client_session:
devices = asyncio.run(connect_and_discover())
with self.assertLogs("ariston.ariston_api", level="DEBUG") as logs:
with patch(
"ariston.ariston_api.aiohttp.ClientSession",
side_effect=[login_session, devices_session],
) as client_session:
devices = asyncio.run(connect_and_discover())

# Every async request must set an explicit total timeout instead of
# relying on aiohttp's 5 minute default.
Expand All @@ -139,6 +142,7 @@ async def connect_and_discover():
self.assertEqual(call.kwargs["timeout"], aiohttp.ClientTimeout(total=30))

self.assertEqual(devices, [{"gw": "gateway-1"}])
self.assertNotIn("async-session-token", "\n".join(logs.output))
self.assertEqual(
login_session.calls[0][0],
("POST", "https://example.test/api/accounts/login"),
Expand Down