summaryrefslogtreecommitdiffstats
path: root/onap-dcae-cbs-docker-client/tests/test_client.py
diff options
context:
space:
mode:
authorTommy Carpenter <tommy@research.att.com>2017-09-25 11:45:12 -0400
committerTommy Carpenter <tommy@research.att.com>2017-09-25 15:49:46 +0000
commit7b31008280fa8b5d45af59f6fd86d49293f14abc (patch)
tree314b8aee8dba5a5ccfb7ea35b599e2eec918c1de /onap-dcae-cbs-docker-client/tests/test_client.py
parente11be5dc15e6800ed6111b7773b9e44571343207 (diff)
Add unit testing to cbs docker client
Issue-ID: DCAEGEN2-60 Change-Id: I4e376ed2b417aceb2927997ff9be8e502829fd86 Signed-off-by: Tommy Carpenter <tommy@research.att.com>
Diffstat (limited to 'onap-dcae-cbs-docker-client/tests/test_client.py')
-rw-r--r--onap-dcae-cbs-docker-client/tests/test_client.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/onap-dcae-cbs-docker-client/tests/test_client.py b/onap-dcae-cbs-docker-client/tests/test_client.py
new file mode 100644
index 0000000..6c9062b
--- /dev/null
+++ b/onap-dcae-cbs-docker-client/tests/test_client.py
@@ -0,0 +1,36 @@
+from onap_dcae_cbs_docker_client.client import get_config
+import requests
+
+class FakeResponse:
+ def __init__(self, status_code, thejson):
+ self.status_code = status_code
+ self.thejson = thejson
+ def raise_for_status(self):
+ pass
+ def json(self):
+ return self.thejson
+
+def test_client(monkeypatch):
+
+ def monkeyed_requests_get(url):
+ #mock all the get calls for existent and non-existent
+ if url == "http://consuldotcom:8500/v1/catalog/service/config_binding_service":
+ return FakeResponse(
+ status_code = 200,
+ thejson = [
+ {"ServiceAddress" : "666.666.666.666",
+ "ServicePort" : 8888
+ }]
+ )
+ elif url == "http://666.666.666.666:8888/service_component/mybestfrienddotcom":
+ return FakeResponse(
+ status_code = 200,
+ thejson = {"key_to_your_heart" : 666})
+
+
+ monkeypatch.setattr('requests.get', monkeyed_requests_get)
+ assert(get_config() == {"key_to_your_heart" : 666})
+
+
+
+