Skip to content

Commit

Permalink
feat: append user agent to default user agent
Browse files Browse the repository at this point in the history
closes #110
  • Loading branch information
SlowMo24 committed Nov 16, 2023
1 parent ebfcbe8 commit f81e9c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ohsome/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def __init__(
else:
self._base_api_url = OHSOME_BASE_API_URL
self._cache = cache or []
if user_agent is not None:
self.user_agent = user_agent
else:
self.user_agent = "ohsome-py/{0}".format(OHSOME_VERSION)

if user_agent is None:
user_agent = "ohsome-py"
self.user_agent = f"ohsome-py/{OHSOME_VERSION} {user_agent}"

self.__session = None

def _session(self):
Expand Down
2 changes: 1 addition & 1 deletion ohsome/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_user_agent(base_client):
resp = base_client._session().get(base_client._url)
used_user_agent = resp.request.headers["user-agent"].split("/")
assert used_user_agent[0] == "ohsome-py"
assert used_user_agent[1] == OHSOME_VERSION
assert used_user_agent[1] == f"{OHSOME_VERSION} ohsome-py"


@pytest.mark.vcr
Expand Down

0 comments on commit f81e9c8

Please sign in to comment.