Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

get_params is now ignored if not set #45

Merged
merged 1 commit into from
Nov 30, 2020
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
2 changes: 2 additions & 0 deletions openrouteservice/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ def _generate_auth_url(path, params):

if type(params) is dict:
params = sorted(dict(**params).items())
elif params is None:
return path

return path + "?" + _urlencode_params(params)

Expand Down
17 changes: 17 additions & 0 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ def test_dry_run(self):

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

@responses.activate
def test_no_get_parameter(self):

responses.add(responses.POST,
'https://api.openrouteservice.org/directions',
body='{"status":"OK","results":[]}',
status=200,
content_type='application/json')

req = self.client.request(post_json={},
url='v2/directions/driving-car/json',
dry_run='true')

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

# Test if the client works with a post request without a get parameter

@responses.activate
def test_key_in_header(self):
# Test that API key is being put in the Authorization header
Expand Down