1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Raise ExternalError on 400+ responses for pug

This commit is contained in:
Steffo 2020-05-28 16:57:10 +02:00
parent bb81bae479
commit 4f1cf50779
Signed by: steffo
GPG key ID: 896A80F55F7C97F0

View file

@ -16,6 +16,8 @@ class PugCommand(rc.Command):
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
async with aiohttp.ClientSession() as session:
async with session.get("https://dog.ceo/api/breed/pug/images/random") as response:
if response.status >= 400:
raise rc.ExternalError(f"Request returned {response.status}")
result = await response.json()
assert "status" in result
assert result["status"] == "success"