Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix non-strings in sendpoi #590

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"