Skip to content

Commit 859f83b

Browse files
authored
Merge pull request #45 from GIScience/get-params-fix
get_params is now ignored if not set
2 parents 7615c33 + 2c0261d commit 859f83b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

openrouteservice/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ def _generate_auth_url(path, params):
263263

264264
if type(params) is dict:
265265
params = sorted(dict(**params).items())
266+
elif params is None:
267+
return path
266268

267269
return path + "?" + _urlencode_params(params)
268270

test/test_client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,23 @@ def test_dry_run(self):
114114

115115
self.assertEqual(0, len(responses.calls))
116116

117+
@responses.activate
118+
def test_no_get_parameter(self):
119+
120+
responses.add(responses.POST,
121+
'https://api.openrouteservice.org/directions',
122+
body='{"status":"OK","results":[]}',
123+
status=200,
124+
content_type='application/json')
125+
126+
req = self.client.request(post_json={},
127+
url='v2/directions/driving-car/json',
128+
dry_run='true')
129+
130+
self.assertEqual(0, len(responses.calls))
131+
132+
# Test if the client works with a post request without a get parameter
133+
117134
@responses.activate
118135
def test_key_in_header(self):
119136
# Test that API key is being put in the Authorization header

0 commit comments

Comments
 (0)