Skip to content

Commit

Permalink
return None on 404 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkdrob authored Sep 7, 2023
1 parent 0caf6c9 commit a588691
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aioskybell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ async def async_send_request( # pylint:disable=too-many-arguments
**kwargs,
)
if response.status == 401:
raise SkybellAuthenticationException(self, await response.text())
raise SkybellAuthenticationException(await response.text())
if response.status == 404:
_LOGGER.exception(await response.text())
return None
response.raise_for_status()
except (ClientConnectorError, ClientError, ClientResponseError) as ex:
if retry:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_skybell.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,21 @@ def activity_camera_image(aresponses: ResponsesMockServer, device: str) -> None:
)


def activity_camera_image_not_found(
aresponses: ResponsesMockServer, device: str
) -> None:
"""Generate activity camera image not found response."""
aresponses.add(
"skybell-thumbnails-stage.s3.amazonaws.com",
f"/{device}/1646859244793-951{device}_{device}.jpeg",
"get",
aresponses.Response(
status=404,
headers={"Content-Type": "image/jpeg"},
),
)


def new_activity_camera_image(aresponses: ResponsesMockServer, device: str) -> None:
"""Generate activity camera image response."""
aresponses.add(
Expand Down Expand Up @@ -596,6 +611,11 @@ async def test_async_refresh_device(
loop = asyncio.get_running_loop()
loop.run_in_executor(None, os.remove(client._cache_path))

device_activities(aresponses, device.device_id)
activity_camera_image_not_found(aresponses, device.device_id)
await device._async_update_activities()
assert device.images["activity"] is None

assert aresponses.assert_no_unused_routes() is None


Expand Down

0 comments on commit a588691

Please sign in to comment.