Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Add test_invalid_data
Browse files Browse the repository at this point in the history
  • Loading branch information
bieniu committed May 3, 2021
1 parent 97eb783 commit 7080f5d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,24 @@ async def test_api_error():
assert str(error.status) == "Invalid response from Zadnego Ale API: 404"

await session.close()


@pytest.mark.asyncio
async def test_invalid_data():
"""Test invalid data."""
session = aiohttp.ClientSession()

with aioresponses() as session_mock, patch(
"zadnegoale.date", today=Mock(return_value=TEST_DATE)
):
session_mock.get(
f"http://api.zadnegoale.pl/dusts/public/date/20210101/region/{VALID_REGION}",
payload="null",
)
zadnegoale = ZadnegoAle(session, VALID_REGION)
try:
await zadnegoale.async_update()
except ApiError as error:
assert str(error.status) == "Invalid response from Zadnego Ale API: null"

await session.close()

0 comments on commit 7080f5d

Please sign in to comment.