Skip to content

Commit

Permalink
Bump mypy from 1.6.1 to 1.7.0 (#346)
Browse files Browse the repository at this point in the history
* Bump mypy from 1.6.1 to 1.7.0

Bumps [mypy](https://github.com/python/mypy) from 1.6.1 to 1.7.0.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](python/mypy@v1.6.1...v1.7.0)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Fix CI

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aaron Bach <[email protected]>
  • Loading branch information
dependabot[bot] and bachya authored Nov 13, 2023
1 parent 912b8d2 commit 9cc6228
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 34 deletions.
57 changes: 29 additions & 28 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions pytile/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ async def async_get_tiles(self) -> dict[str, Tile]:

data = {}
for tile_uuid, result in zip(details_tasks, results):
if isinstance(result, RequestError):
if "412" in str(result):
# Tile Labels will return an HTTP 412 because they don't have
# additional details; we can safely ignore these errors and still
# track the Tile (without additional details):
continue
if isinstance(result, RequestError) and "412" in str(result):
# Tile Labels will return an HTTP 412 because they don't have
# additional details; we can safely ignore these errors and still
# track the Tile (without additional details):
continue
if isinstance(result, BaseException):
LOGGER.error("Error requesting details for %s: %s", tile_uuid, result)
continue
data[tile_uuid] = Tile(self._async_request, result)

return data
Expand Down
46 changes: 46 additions & 0 deletions tests/test_tile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Define tests for the client object."""
import logging
from datetime import datetime
from typing import Any
from unittest.mock import Mock

import aiohttp
import pytest
Expand Down Expand Up @@ -140,6 +142,50 @@ async def test_get_tiles(
aresponses.assert_plan_strictly_followed()


@pytest.mark.asyncio
async def test_get_tiles_http_error(
aresponses: ResponsesMockServer,
authenticated_tile_api_server: ResponsesMockServer,
caplog: Mock,
tile_states_response: dict[str, Any],
) -> None:
"""Test getting all Tiles associated with an account.
Args:
aresponses: An aresponses server.
authenticated_tile_api_server: A mock Tile API server connection.
caplog: A mocked logging utility.
tile_states_response: An API response payload.
"""
caplog.set_level(logging.INFO)

async with authenticated_tile_api_server:
authenticated_tile_api_server.add(
"production.tile-api.com",
"/api/v1/tiles/tile_states",
"get",
response=aiohttp.web_response.json_response(
tile_states_response, status=200
),
)
authenticated_tile_api_server.add(
"production.tile-api.com",
f"/api/v1/tiles/{TILE_TILE_UUID}",
"get",
response=aresponses.Response(text=None, status=500),
)

async with aiohttp.ClientSession() as session:
api = await async_login(
TILE_EMAIL, TILE_PASSWORD, session, client_uuid=TILE_CLIENT_UUID
)
tiles = await api.async_get_tiles()
assert len(tiles) == 0
assert any("Error requesting details" in e.message for e in caplog.records)

aresponses.assert_plan_strictly_followed()


@pytest.mark.asyncio
async def test_missing_last_tile_state(
aresponses: ResponsesMockServer,
Expand Down

0 comments on commit 9cc6228

Please sign in to comment.