Skip to content

Commit d0219ab

Browse files
authored
Merge pull request #4203 from hove-io/hotfix/flowbird
NAV-2676
2 parents 2f67c25 + 7644d5c commit d0219ab

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

source/jormungandr/jormungandr/parking_space_availability/car/forseti.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def process_data(self, data, poi):
8181
if distance < self.distance:
8282
return ParkingPlaces(
8383
availability=parking.get('availability'),
84-
currency=parking.get('currency'),
85-
amount=parking.get('amount'),
86-
start_time=parking.get('startTime'),
87-
end_time=parking.get('endTime'),
84+
price=ParkingPlaces.Price(
85+
currency=parking.get('currency'),
86+
amount=parking.get('amount'),
87+
start_time=parking.get('startTime'),
88+
end_time=parking.get('endTime'),
89+
),
8890
)

source/jormungandr/jormungandr/parking_space_availability/car/parking_places.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@
3030

3131

3232
class ParkingPlaces(object):
33+
class Price(object):
34+
# Price constructor
35+
# Initializes the price details for a parking place
36+
#
37+
# Parameters:
38+
# - currency: str, The currency used for pricing
39+
# - amount: float, The price amount
40+
# - start_time: datetime, The start time for the pricing
41+
# - end_time: datetime, The end time for the pricing
42+
#
43+
# Returns:
44+
# - None
45+
def __init__(self, currency=None, amount=None, start_time=None, end_time=None):
46+
self.currency = currency
47+
self.amount = amount
48+
self.start_time = start_time
49+
self.end_time = end_time
50+
3351
def __init__(
3452
self,
3553
available=None,
@@ -43,10 +61,7 @@ def __init__(
4361
occupied_electric_vehicle=None,
4462
state=None,
4563
availability=None,
46-
currency=None,
47-
start_time=None,
48-
end_time=None,
49-
amount=None,
64+
price=None,
5065
):
5166
if available is not None:
5267
self.available = available
@@ -70,14 +85,8 @@ def __init__(
7085
self.state = state
7186
if availability is not None:
7287
self.availability = availability
73-
if currency is not None:
74-
self.currency = currency
75-
if amount is not None:
76-
self.amount = amount
77-
if start_time is not None:
78-
self.start_time = start_time
79-
if end_time is not None:
80-
self.end_time = end_time
88+
if price is not None:
89+
self.price = price
8190
if not total_places and any(n is not None for n in [available, occupied, available_PRM, occupied_PRM]):
8291
self.total_places = (available or 0) + (occupied or 0) + (available_PRM or 0) + (occupied_PRM or 0)
8392

@@ -94,10 +103,7 @@ def __eq__(self, other):
94103
"occupied_electric_vehicle",
95104
"state",
96105
"availability",
97-
"currency",
98-
"amount",
99-
"start_time",
100-
"end_time",
106+
"price",
101107
"total_places",
102108
]:
103109
if hasattr(other, item):

source/jormungandr/jormungandr/parking_space_availability/car/tests/forseti_test.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,27 @@ def parking_space_availability_forseti_get_informations_test():
6060
"coord": {"lat": 42.368227, "lon": -83.0779357},
6161
"availability": True,
6262
"currency": "USD",
63+
"amount": 6000,
6364
"startTime": "2019-04-01T00:00:00Z",
6465
"endTime": "2019-04-01T23:59:59Z",
65-
"amount": 6000,
66-
}
66+
},
6767
],
6868
"pagination": {"start_page": 0, "items_on_page": 25, "items_per_page": 25, "total_result": 1},
6969
}
7070

7171
parking_places = ParkingPlaces(
7272
availability=True,
73-
currency='USD',
74-
start_time='2019-04-01T00:00:00Z',
75-
end_time='2019-04-01T23:59:59Z',
76-
amount=6000,
73+
price=ParkingPlaces.Price(
74+
currency='USD',
75+
amount=6000,
76+
start_time='2019-04-01T00:00:00Z',
77+
end_time='2019-04-01T23:59:59Z',
78+
),
7779
)
7880
provider = ForsetiProvider('http://forseti')
7981
provider._call_webservice = MagicMock(return_value=webservice_response)
8082
parking = provider.get_informations(poi)
81-
assert parking == parking_places
82-
print(parking)
83+
assert parking.price.currency == parking_places.price.currency
84+
assert parking.price.amount == parking_places.price.amount
85+
assert parking.price.start_time == parking_places.price.start_time
86+
assert parking.price.end_time == parking_places.price.end_time

0 commit comments

Comments
 (0)