Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "setup Connected Services Error" due to latest API Changes #240

Merged
merged 10 commits into from
Nov 12, 2023
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false

steps:
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.2.2
poetry-version: 1.5.1

- name: Install dependencies
run: poetry install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Pre-commit
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
env:
OS: ubuntu-latest
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.2.2
poetry-version: 1.5.1

- name: Install dependencies
run: poetry install
Expand Down
12 changes: 10 additions & 2 deletions mytoyota/models/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ def is_connected_services_enabled(self) -> bool:
if self.vin and self._connected_services:
if (
"connectedService" in self._connected_services
and "status" in self._connected_services["connectedService"]
and "devices" in self._connected_services["connectedService"]
):
if self._connected_services["connectedService"]["status"] == "ACTIVE":
vin_specific_connected_service = None
for device in self._connected_services["connectedService"]["devices"]:
if device.get("vin") == self.vin:
vin_specific_connected_service = device
break
if (
vin_specific_connected_service
and vin_specific_connected_service.get("state") == "ACTIVE"
):
return True

_LOGGER.error(
Expand Down
691 changes: 276 additions & 415 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ description = "Python client for Toyota Connected Services."
authors = ["Simon Grud Hansen <[email protected]>"]
license = "MIT"
readme = "README.md"
version = "0.9.2"
version = "0.9.3"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
keywords = [
"Toyota",
Expand All @@ -26,7 +26,7 @@ repository = "https://github.com/DurgNomis-drol/mytoyota"
"Release Notes" = "https://github.com/DurgNomis-drol/mytoyota/releases"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
langcodes = "^3.1"
httpx = ">=0.18.1"
arrow = "^1.1"
Expand All @@ -38,7 +38,7 @@ black = ">=22.3, !=22.10.0" # https://github.com/psf/black/issues/3312
flake8 = "^3.8.4"
flake8-bugbear = "^22.10.27"
flake8-comprehensions = "^3.4.0"
pylint = "^2.7.2"
pylint = "^3.0.2"
isort = "^5.10.1"
codespell = "^2.0.0"
pytest = "^7.2.0"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_hvac.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from mytoyota.models.hvac import Hvac

# pylint: disable=no-self-use


class TestHvac:
"""pytest functions to test Hvac"""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_myt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
)
from mytoyota.models.trip import DetailedTrip, Trip, TripEvent

# pylint: disable=no-self-use


class OfflineController:
"""Provides a Controller class that can be used for testing."""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_myt_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from mytoyota.client import MyT
from mytoyota.exceptions import ToyotaLoginError

# pylint: disable=no-self-use


class TestMyTOnline:
"""pytest functions to test MyT using the online services"""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_parking_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from mytoyota.models.location import ParkingLocation # pylint: disable=import-error

# pylint: disable=no-self-use


class TestParkingLocation:
"""pytest functions to test ParkingLocation"""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
Windows,
)

# pylint: disable=no-self-use


class TestSensors: # pylint: disable=too-many-public-methods
"""pytest functions to test Sensors"""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

from mytoyota.statistics import Statistics

# pylint: disable=no-self-use


class TestStatistics:
"""pytest functions to test Statistics"""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import pytest

from mytoyota.exceptions import ToyotaInvalidToken

# pylint: disable=no-self-use
from mytoyota.utils.conversions import (
convert_to_liter_per_100_miles,
convert_to_miles,
Expand Down
2 changes: 0 additions & 2 deletions tests/test_utils_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from mytoyota.utils.logs import censor, censor_dict, censor_vin

# pylint: disable=no-self-use


class TestLogUtilities:
"""pytest functions for testing logs"""
Expand Down
38 changes: 33 additions & 5 deletions tests/test_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from mytoyota.models.sensors import Sensors
from mytoyota.models.vehicle import Vehicle

# pylint: disable=no-self-use


class TestVehicle:
"""pytest functions for Vehicle object"""
Expand Down Expand Up @@ -92,7 +90,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")
Expand Down Expand Up @@ -134,7 +142,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,
)
Expand Down Expand Up @@ -175,7 +193,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,
)
Expand Down