1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
"""Test the garages on exceptions."""
from __future__ import annotations
import pytest
from aresponses import ResponsesMockServer
from odp_amsterdam import ODPAmsterdam, ODPAmsterdamError, ODPAmsterdamResultsError
from . import load_fixtures
async def test_wrong_garage_model(
aresponses: ResponsesMockServer,
odp_amsterdam_client: ODPAmsterdam,
) -> None:
"""Test a wrong garage model."""
aresponses.add(
"p-info.vorin-amsterdam.nl",
"/v1/ParkingLocation.json",
"GET",
aresponses.Response(
status=200,
headers={"Content-Type": "text/plain"},
text=load_fixtures("wrong_garages.json"),
),
)
with pytest.raises(ODPAmsterdamError):
await odp_amsterdam_client.all_garages()
async def test_no_garage_found(
aresponses: ResponsesMockServer,
odp_amsterdam_client: ODPAmsterdam,
) -> None:
"""Test a wrong garage model."""
aresponses.add(
"p-info.vorin-amsterdam.nl",
"/v1/ParkingLocation.json",
"GET",
aresponses.Response(
status=200,
headers={"Content-Type": "text/plain"},
text=load_fixtures("garages.json"),
),
)
with pytest.raises(ODPAmsterdamResultsError):
await odp_amsterdam_client.garage(garage_id="test")
|