Skip to content

Commit

Permalink
Fix non-strings in sendpoi (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe authored Jan 23, 2024
1 parent 5eb68d8 commit 3962024
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bimmer_connected/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class PointOfInterest:
def __post_init__(self, lat, lon, street, postal_code, city, country):
self.coordinates = GPSPosition(lat, lon)

self.locationAddress = PointOfInterestAddress(street, postal_code, city, country)
self.locationAddress = PointOfInterestAddress(str(street), str(postal_code), str(city), str(country))

if not self.formattedAddress:
self.formattedAddress = ", ".join([i for i in [street, postal_code, city] if i]) or "Coordinates only"
self.formattedAddress = ", ".join([str(i) for i in [street, postal_code, city] if i]) or "Coordinates only"


class ValueWithUnit(NamedTuple):
Expand Down
7 changes: 7 additions & 0 deletions bimmer_connected/tests/test_remote_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,10 @@ def test_poi_parsing():
assert poi_data.coordinates.longitude == POI_DATA["lon"]
assert poi_data.name == "Sent with ♥ by bimmer_connected"
assert poi_data.formattedAddress == "Somewhere over rainbow"

# Check parsing with numeric postal code
poi_data = PointOfInterest(lat=POI_DATA["lat"], lon=POI_DATA["lon"], postal_code=1234)
assert poi_data.coordinates.latitude == POI_DATA["lat"]
assert poi_data.coordinates.longitude == POI_DATA["lon"]
assert poi_data.name == "Sent with ♥ by bimmer_connected"
assert poi_data.locationAddress.postalCode == "1234"

0 comments on commit 3962024

Please sign in to comment.