Skip to content

Commit

Permalink
Adjust tests for Toyota Supra
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed Jul 1, 2024
1 parent bb7cff2 commit 0cda104
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions bimmer_connected/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
VIN_I01_NOREX = "WBY000000NOREXI01"
VIN_I01_REX = "WBY00000000REXI01"
VIN_I20 = "WBA00000000DEMO01"
VIN_J29 = "WZ100000000000J29"

ALL_VEHICLES: Dict[str, Dict] = {brand.value: {} for brand in CarBrands}
ALL_PROFILES: Dict[str, Dict] = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"gcid": "ceb64158-d2ca-47e9-9ee6-cbffb881434e",
"mappingInfos": []
}
14 changes: 9 additions & 5 deletions bimmer_connected/tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bimmer_connected.api.authentication import MyBMWAuthentication, MyBMWLoginRetry
from bimmer_connected.api.client import MyBMWClient
from bimmer_connected.api.regions import get_region_from_name
from bimmer_connected.const import ATTR_CAPABILITIES, VEHICLES_URL
from bimmer_connected.const import ATTR_CAPABILITIES, VEHICLES_URL, CarBrands
from bimmer_connected.models import GPSPosition, MyBMWAPIError, MyBMWAuthError, MyBMWQuotaError

from . import (
Expand Down Expand Up @@ -448,8 +448,10 @@ async def test_429_retry_ok_vehicles(caplog, bmw_fixture: respx.Router):
side_effect=[
httpx.Response(429, json=json_429),
httpx.Response(429, json=json_429),
httpx.Response(200, json=load_response(RESPONSE_DIR / "bmw-eadrax-vcs_v5_vehicle-list.json")),
httpx.Response(200, json=load_response(RESPONSE_DIR / "mini-eadrax-vcs_v5_vehicle-list.json")),
*[
httpx.Response(200, json=load_response(RESPONSE_DIR / f"{brand.value}-eadrax-vcs_v5_vehicle-list.json"))
for brand in CarBrands
],
]
)
caplog.set_level(logging.DEBUG)
Expand Down Expand Up @@ -498,8 +500,10 @@ async def test_429_retry_with_login_ok_vehicles(bmw_fixture: respx.Router):
side_effect=[
httpx.Response(429, json=json_429),
httpx.Response(429, json=json_429),
httpx.Response(200, json=load_response(RESPONSE_DIR / "bmw-eadrax-vcs_v5_vehicle-list.json")),
httpx.Response(200, json=load_response(RESPONSE_DIR / "mini-eadrax-vcs_v5_vehicle-list.json")),
*[
httpx.Response(200, json=load_response(RESPONSE_DIR / f"{brand.value}-eadrax-vcs_v5_vehicle-list.json"))
for brand in CarBrands
],
]
)

Expand Down
3 changes: 2 additions & 1 deletion bimmer_connected/tests/test_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
VIN_I01_NOREX,
VIN_I01_REX,
VIN_I20,
VIN_J29,
get_deprecation_warning_count,
)
from .conftest import prepare_account_with_vehicles
Expand Down Expand Up @@ -94,6 +95,7 @@ async def test_drive_train_attributes(caplog, bmw_fixture: respx.Router):
VIN_I01_NOREX: (False, True),
VIN_I01_REX: (True, True),
VIN_I20: (False, True),
VIN_J29: (True, False),
}

for vehicle in account.vehicles:
Expand All @@ -117,7 +119,6 @@ async def test_parsing_of_lsc_type(caplog, bmw_fixture: respx.Router):
def test_car_brand(caplog, bmw_fixture: respx.Router):
"""Test CarBrand enum."""
assert CarBrands("BMW") == CarBrands("bmw")
assert CarBrands("DRITTKUNDE") == CarBrands("toyota")

with pytest.raises(ValueError):
CarBrands("Audi")
Expand Down
12 changes: 10 additions & 2 deletions bimmer_connected/tests/test_vehicle_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
VIN_I01_NOREX,
VIN_I01_REX,
VIN_I20,
VIN_J29,
get_deprecation_warning_count,
)
from .conftest import prepare_account_with_vehicles
Expand Down Expand Up @@ -69,9 +70,16 @@ async def test_generic_error_handling(caplog, bmw_fixture: respx.Router):


@pytest.mark.asyncio
async def test_range_combustion_no_info(caplog, bmw_fixture: respx.Router):
@pytest.mark.parametrize(
("vin"),
[
(VIN_F31),
(VIN_J29),
],
)
async def test_range_combustion_no_info(caplog, bmw_fixture: respx.Router, vin: str):
"""Test if the parsing of very old vehicles."""
vehicle = (await prepare_account_with_vehicles()).get_vehicle(VIN_F31)
vehicle = (await prepare_account_with_vehicles()).get_vehicle(vin)
status = vehicle.fuel_and_battery

assert status.remaining_fuel == (None, None)
Expand Down

0 comments on commit 0cda104

Please sign in to comment.