Skip to content

Commit

Permalink
client: use colon to decide on protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Feb 9, 2021
1 parent 7bb1bdf commit 39cca14
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __init__(self, apikey=None, headers=None, host=None):
self.apikey = apikey
self.headers = {"x-api-key": apikey} if apikey else headers
self.host = host
self.protocol = "http" if host.startswith("localhost") else "https"
self.protocol = "http" if ":" in host else "https"
self.url = f"{self.protocol}://{self.host}"

if "swagger_spec" not in self.__dict__ or (
Expand Down
7 changes: 0 additions & 7 deletions mpcontribs-client/mpcontribs/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ def test_validate_email():
),
)
def test_Client():
kwargs = {"host": "localhost"}
spec = Client(**kwargs).swagger_spec
assert spec.http_client.headers == {}
assert spec.origin_url == "http://localhost/apispec.json"
assert spec.spec_dict["host"] == "localhost"
assert spec.spec_dict["schemes"] == ["http"]
assert spec.user_defined_formats["email"] == email_format
kwargs = {"apikey": "1234"}
spec = Client(**kwargs).swagger_spec
assert spec.http_client.headers == {"x-api-key": "1234"}
Expand Down

0 comments on commit 39cca14

Please sign in to comment.