summaryrefslogtreecommitdiffstats
path: root/awxkit/test/test_ws.py
diff options
context:
space:
mode:
authorRyan Petrello <rpetrell@redhat.com>2019-08-09 04:12:31 +0200
committerRyan Petrello <rpetrell@redhat.com>2019-08-09 04:12:31 +0200
commit9616cc6f7856523ebf6d1580443313296c9f6507 (patch)
treef4c08a5263b363da903c4a4176ca18fcd9b2cb55 /awxkit/test/test_ws.py
parentMerge pull request #4444 from elyezer/app-token-e2e (diff)
downloadawx-9616cc6f7856523ebf6d1580443313296c9f6507.tar.xz
awx-9616cc6f7856523ebf6d1580443313296c9f6507.zip
import awxkit
Co-authored-by: Christopher Wang <cwang@ansible.com> Co-authored-by: Jake McDermott <jmcdermott@ansible.com> Co-authored-by: Jim Ladd <jladd@redhat.com> Co-authored-by: Elijah DeLee <kdelee@redhat.com> Co-authored-by: Alan Rominger <arominge@redhat.com> Co-authored-by: Yanis Guenane <yanis@guenane.org>
Diffstat (limited to 'awxkit/test/test_ws.py')
-rw-r--r--awxkit/test/test_ws.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/awxkit/test/test_ws.py b/awxkit/test/test_ws.py
new file mode 100644
index 0000000000..afc6b42fc5
--- /dev/null
+++ b/awxkit/test/test_ws.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from collections import namedtuple
+
+from unittest.mock import patch
+import pytest
+
+from awxkit.ws import WSClient
+
+ParseResult = namedtuple("ParseResult", ["port", "hostname", "secure"])
+
+def test_explicit_hostname():
+ client = WSClient("token", "some-hostname", 556, False)
+ assert client.port == 556
+ assert client.hostname == "some-hostname"
+ assert client._use_ssl == False
+ assert client.token == "token"
+
+
+@pytest.mark.parametrize('url, result',
+ [['https://somename:123', ParseResult(123, "somename", True)],
+ ['http://othername:456', ParseResult(456, "othername", False)],
+ ['http://othername', ParseResult(80, "othername", False)],
+ ['https://othername', ParseResult(443, "othername", True)],
+])
+def test_urlparsing(url, result):
+ with patch("awxkit.ws.config") as mock_config:
+ mock_config.base_url = url
+
+ client = WSClient("token")
+ assert client.port == result.port
+ assert client.hostname == result.hostname
+ assert client._use_ssl == result.secure