Skip to content

Commit

Permalink
Fix sendpoi (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe authored Nov 29, 2024
1 parent 8d845fc commit d0c8f7c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bimmer_connected/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ def __post_init__(self, lat, lon, name, street, postal_code, city, country):
position = GPSPosition(lat, lon)
self.position = {
"lat": position.latitude,
"lon": position.longitude,
"lng": position.longitude,
}

self.address = PointOfInterestAddress(str(street), str(postal_code), str(city), str(country))
self.category = {"losCategory": "Address", "mguVehicleCategoryId": None, "name": "Address"}
self.entrances = [{"name": None, "position": self.position}]
self.title = name

if not self.formattedAddress:
Expand Down
2 changes: 1 addition & 1 deletion bimmer_connected/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def poi_sideeffect(request: httpx.Request, gcid: str) -> httpx.Response:
[
len(data["vehicleInformation"]["vin"]) == 17,
isinstance(data["places"][0]["position"]["lat"], float),
isinstance(data["places"][0]["position"]["lon"], float),
isinstance(data["places"][0]["position"]["lng"], float),
len(data["places"][0]["title"]) > 0,
]
)
Expand Down
8 changes: 4 additions & 4 deletions bimmer_connected/tests/test_remote_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,27 +400,27 @@ def test_poi_parsing():
# Check parsing of attributes required by API
poi_data = PointOfInterest(**POI_DATA)
assert poi_data.position["lat"] == POI_DATA["lat"]
assert poi_data.position["lon"] == POI_DATA["lon"]
assert poi_data.position["lng"] == POI_DATA["lon"]
assert poi_data.title == POI_DATA["name"]
assert poi_data.formattedAddress == f"{POI_DATA['street']}, {POI_DATA['postal_code']}, {POI_DATA['city']}"

# Check the default attributes
poi_data = PointOfInterest(lat=POI_DATA["lat"], lon=POI_DATA["lon"])
assert poi_data.position["lat"] == POI_DATA["lat"]
assert poi_data.position["lon"] == POI_DATA["lon"]
assert poi_data.position["lng"] == POI_DATA["lon"]
assert poi_data.title == "Sent with ♥ by bimmer_connected"
assert poi_data.formattedAddress == "Coordinates only"

# Check the default attributes with formatted address
poi_data = PointOfInterest(lat=POI_DATA["lat"], lon=POI_DATA["lon"], formattedAddress="Somewhere over rainbow")
assert poi_data.position["lat"] == POI_DATA["lat"]
assert poi_data.position["lon"] == POI_DATA["lon"]
assert poi_data.position["lng"] == POI_DATA["lon"]
assert poi_data.title == "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.position["lat"] == POI_DATA["lat"]
assert poi_data.position["lon"] == POI_DATA["lon"]
assert poi_data.position["lng"] == POI_DATA["lon"]
assert poi_data.title == "Sent with ♥ by bimmer_connected"
assert poi_data.address.postalCode == "1234"

0 comments on commit d0c8f7c

Please sign in to comment.