Skip to content

Commit

Permalink
Fix empty vehicle type
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsbalu committed Feb 14, 2019
1 parent 5319b79 commit 3ea22a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion WazeRouteCalculator/WazeRouteCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def get_route(self, npaths=1, time_delta=0):
url_options = {
"from": "x:%s y:%s" % (self.start_coords["lon"], self.start_coords["lat"]),
"to": "x:%s y:%s" % (self.end_coords["lon"], self.end_coords["lat"]),
"vehicleType": self.vehicle_type,
"at": time_delta,
"returnJSON": "true",
"returnGeometries": "true",
Expand All @@ -97,6 +96,8 @@ def get_route(self, npaths=1, time_delta=0):
"nPaths": npaths,
"options": "AVOID_TRAILS:t",
}
if self.vehicle_type:
url_options["vehicleType"] = self.vehicle_type

for routing_srv in routing_servers:
response = requests.get(self.WAZE_URL + routing_srv, params=url_options, headers=self.HEADERS)
Expand Down
10 changes: 10 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,13 @@ def test_vehicle_motor(self):
route = wrc.WazeRouteCalculator(from_address, to_address, vehicle_type='MOTORCYCLE')
route.get_route()
assert 'vehicletype=motorcycle' in req.last_request.query

def test_empty_vehicle_type(self):
from_address = 'From address'
to_address = 'To address'
with requests_mock.mock() as m:
m.get(self.address_req, text=self.address_to_coords_response)
req = m.get(self.routing_req, text=self.routing_response)
route = wrc.WazeRouteCalculator(from_address, to_address)
route.get_route()
assert 'vehicletype' not in req.last_request.query

0 comments on commit 3ea22a5

Please sign in to comment.