aboutsummaryrefslogtreecommitdiffstats
path: root/python_moonutilities/tests/unit_python/test_configuration.py
diff options
context:
space:
mode:
authorsgdt6900 <rhanafy.ext@orange.com>2017-12-25 16:13:21 +0200
committersgdt6900 <rhanafy.ext@orange.com>2018-01-03 14:40:39 +0200
commit6350d625b4e4627fc6886c3d7f052c67abf0989f (patch)
treea9b3ed096a1c6b05590c5b2eedfa3a0ae4dd339e /python_moonutilities/tests/unit_python/test_configuration.py
parent52d037e757ac2189978e1129f469929fe73a9b7f (diff)
adding comments for the cases should be handled for configuration module
refactoring url of component port to match same pattern integrating request wrapper adding validation for the key in the object before accessing it update some conditions uncomment required test cases after validation done Change-Id: I5f0e22ca4fd803992c051ec238f91ed0703cd1a2 Signed-off-by: sgdt6900 <rhanafy.ext@orange.com>
Diffstat (limited to 'python_moonutilities/tests/unit_python/test_configuration.py')
-rw-r--r--python_moonutilities/tests/unit_python/test_configuration.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/python_moonutilities/tests/unit_python/test_configuration.py b/python_moonutilities/tests/unit_python/test_configuration.py
index 10618f1c..8ca389bf 100644
--- a/python_moonutilities/tests/unit_python/test_configuration.py
+++ b/python_moonutilities/tests/unit_python/test_configuration.py
@@ -5,7 +5,7 @@ import requests_mock
def test_get_configuration_success():
from python_moonutilities import configuration
- assert configuration.get_configuration("components/port_start")["components/port_start"] == comp_util.CONF["components"]["port_start"]
+ assert configuration.get_configuration("components/port_start")["port_start"] == comp_util.CONF["components"]["port_start"]
@requests_mock.Mocker(kw='mock')
@@ -18,27 +18,24 @@ def test_get_configuration_not_found(**kwargs):
configuration.get_configuration("components/port_start_wrong")
assert str(exception_info.value) == '500: Consul error'
-
-# [TODO] this test used to test the invalid response
-# it should be un commented and run after refactoring the related part
@requests_mock.Mocker(kw='mock')
def test_get_configuration_invalid_response(**kwargs):
from python_moonutilities import configuration
- kwargs['mock'].get('http://consul:8500/v1/kv/components_port_start', json=[
- {"components_port_start":'components_port_start', 'Value': comp_util.get_b64_conf("components/port_start")}
+ kwargs['mock'].get('http://consul:8500/v1/kv/components/port_start', json=[
+ {"port_start":'port_start', 'Value': comp_util.get_b64_conf("components/port_start")}
])
- # with pytest.raises(Exception) as exception_info:
- # configuration.get_configuration("components_port_start")
- # assert str(exception_info.value) == '500: Consul error'
+ with pytest.raises(Exception) as exception_info:
+ configuration.get_configuration("components/port_start")
+ assert str(exception_info.value) == '500: Consul error'
@requests_mock.Mocker(kw='mock')
def test_put_increment_port_failure(**kwargs):
from python_moonutilities import configuration
- kwargs['mock'].put('http://consul:8500/v1/kv/components_port_start', json=[], status_code=400)
- kwargs['mock'].get('http://consul:8500/v1/kv/components_port_start', json=[
- {'Key': 'components_port_start', 'Value': comp_util.get_b64_conf("components/port_start")}
+ kwargs['mock'].put('http://consul:8500/v1/kv/components/port_start', json=[], status_code=400)
+ kwargs['mock'].get('http://consul:8500/v1/kv/components/port_start', json=[
+ {'Key': 'port_start', 'Value': comp_util.get_b64_conf("components/port_start")}
], status_code=200)
with pytest.raises(Exception) as exception_info:
configuration.increment_port()