Skip to content

Commit

Permalink
Allow tire target pressure to be empty (#531)
Browse files Browse the repository at this point in the history
* Update pre-commit

* Don't fail if no target pressure
  • Loading branch information
rikroe authored May 5, 2023
1 parent 09d2774 commit bd6e0f1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.251
rev: v0.0.265
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
args:
- --safe
- --quiet
files: ^((bimmer_connected|test)/.+)?[^/]+\.py$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.4
hooks:
- id: codespell
args:
Expand All @@ -24,7 +24,7 @@ repos:
exclude_types: [csv, json]
exclude: ^test/responses/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
rev: v1.2.0
hooks:
- id: mypy
name: mypy
Expand Down
2 changes: 1 addition & 1 deletion bimmer_connected/vehicle/tires.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TireState:

def __init__(self, status: Dict, details: Optional[Dict] = None):
self.current_pressure: int = status["currentPressure"]
self.target_pressure: int = status["targetPressure"]
self.target_pressure: Optional[int] = status.get("targetPressure")
self.season: Optional[int] = None
self.manufacturing_week: Optional[datetime] = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
"status": {
"currentPressure": 241,
"pressureStatus": 0,
"targetPressure": 269,
"wearStatus": 0
}
},
Expand All @@ -221,7 +220,6 @@
"status": {
"currentPressure": 255,
"pressureStatus": 0,
"targetPressure": 269,
"wearStatus": 0
}
},
Expand All @@ -243,7 +241,6 @@
"status": {
"currentPressure": 324,
"pressureStatus": 0,
"targetPressure": 303,
"wearStatus": 0
}
},
Expand All @@ -265,7 +262,6 @@
"status": {
"currentPressure": 331,
"pressureStatus": 0,
"targetPressure": 303,
"wearStatus": 0
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/test_vehicle_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,13 @@ async def test_tires():
assert tires.front_left.manufacturing_week is None
assert tires.front_left.season is None

# Vehicle with current tire pressure and details, but no target pressure
tires = account.get_vehicle(VIN_G20).tires
assert tires.front_left.current_pressure == 241
assert tires.front_left.target_pressure is None
assert tires.front_left.manufacturing_week == datetime.datetime(2021, 10, 4, 0, 0)
assert tires.front_left.season == 2

# Vehicle with details
tires = account.get_vehicle(VIN_G70).tires
assert tires.rear_left.current_pressure == 261
Expand Down

0 comments on commit bd6e0f1

Please sign in to comment.