summaryrefslogtreecommitdiffstats
path: root/onap-dcae-cbs-docker-client/tests/test_client.py
diff options
context:
space:
mode:
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
index 132ab33..3b10923 100644
--- a/onap-dcae-cbs-docker-client/tests/test_client.py
+++ b/onap-dcae-cbs-docker-client/tests/test_client.py
@@ -1,5 +1,6 @@
# ================================================================================
# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2021 Nokia. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -77,3 +78,38 @@ def test_badenv(monkeypatch):
get_config()
with pytest.raises(ENVsMissing):
get_all()
+
+
+def test_http_with_env(monkeypatch, monkeyed_requests_get_with_env):
+ monkeypatch.setattr("requests.get", monkeyed_requests_get_with_env)
+
+ assert get_config() == {"key_to_your_heart": "test_env"}
+
+ assert get_all() == {
+ "config": {"key_to_your_heart": "test_env"},
+ "dti": {"some amazing": "dti stuff"},
+ "policies": {"event": {"foo": "bar"}, "items": [{"foo2": "bar2"}]},
+ "otherkey": {"foo3": "bar3"},
+ }
+
+
+def test_https_with_env(monkeypatch, monkeyed_requests_get_https_env):
+ monkeypatch.setattr("requests.get", monkeyed_requests_get_https_env)
+ monkeypatch.setenv("DCAE_CA_CERTPATH", "1")
+
+ assert get_config() == {"key_to_your_heart": "test_env"}
+
+ assert get_all() == {
+ "config": {"key_to_your_heart": "test_env"},
+ "dti": {"some amazing": "dti stuff"},
+ "policies": {"event": {"foo": "bar"}, "items": [{"foo2": "bar2"}]},
+ "otherkey": {"foo3": "bar3"},
+ }
+
+
+def test_http_with_wrong_env(monkeypatch, monkeyed_requests_get_http_with_wrong_env):
+ monkeypatch.setattr("requests.get", monkeyed_requests_get_http_with_wrong_env)
+ with pytest.raises(ENVsMissing):
+ get_config()
+ with pytest.raises(ENVsMissing):
+ get_all()