From 6984d798da79ffc7e320ad6caddda4f31171a50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B6rrle?= Date: Thu, 9 Nov 2023 13:30:24 +0100 Subject: [PATCH] Fix linting and adjust tests --- mytoyota/models/vehicle.py | 2 +- tests/test_vehicle.py | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/mytoyota/models/vehicle.py b/mytoyota/models/vehicle.py index c9403869..a8da1372 100644 --- a/mytoyota/models/vehicle.py +++ b/mytoyota/models/vehicle.py @@ -85,7 +85,7 @@ def is_connected_services_enabled(self) -> bool: ): vin_specific_connected_service = None for device in self._connected_services["connectedService"]["devices"]: - if (device.get("vin") == self.vin): + if device.get("vin") == self.vin: vin_specific_connected_service = device break if vin_specific_connected_service["state"] == "ACTIVE": diff --git a/tests/test_vehicle.py b/tests/test_vehicle.py index f213126a..64fc631e 100644 --- a/tests/test_vehicle.py +++ b/tests/test_vehicle.py @@ -92,7 +92,17 @@ def test_vehicle_init(self): for veh in vehicle_fixtures: vehicle = Vehicle( vehicle_info=veh, - connected_services={"connectedService": {"status": "ACTIVE"}}, + connected_services={ + "connectedService": { + "devices": [ + { + "brand": "TOYOTA", + "state": "ACTIVE", + "vin": veh.get("vin"), + } + ] + } + }, ) assert vehicle.vin == veh.get("vin") @@ -134,7 +144,17 @@ def test_vehicle_init_status(self): vehicle = Vehicle( vehicle_info=vehicle_fixtures[0], - connected_services={"connectedService": {"status": "ACTIVE"}}, + connected_services={ + "connectedService": { + "devices": [ + { + "brand": "TOYOTA", + "state": "ACTIVE", + "vin": vehicle_fixtures[0].get("vin"), + } + ] + } + }, odometer=odometer_fixture, status=status_fixture, ) @@ -175,7 +195,17 @@ def test_vehicle_init_status_legacy(self): vehicle = Vehicle( vehicle_info=vehicle_fixtures[0], - connected_services={"connectedService": {"status": "ACTIVE"}}, + connected_services={ + "connectedService": { + "devices": [ + { + "brand": "TOYOTA", + "state": "ACTIVE", + "vin": vehicle_fixtures[0].get("vin"), + } + ] + } + }, odometer=odometer_fixture, status_legacy=status_fixture, )