aboutsummaryrefslogtreecommitdiffstats
path: root/python_moonutilities/tests
diff options
context:
space:
mode:
authorRuan HE <ruan.he@orange.com>2018-01-03 13:27:25 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-01-03 13:27:25 +0000
commit6d73ea7305c469fc983f29d85743663877fe0882 (patch)
treea0d4cd978c6993dc87e8aaedf134d0dcb4dcda8f /python_moonutilities/tests
parent073e1a3033b150c01c7001e8784881497b1d32a2 (diff)
parent6350d625b4e4627fc6886c3d7f052c67abf0989f (diff)
Merge "adding comments for the cases should be handled for configuration module"
Diffstat (limited to 'python_moonutilities/tests')
-rw-r--r--python_moonutilities/tests/unit_python/mock_repo/urls.py6
-rw-r--r--python_moonutilities/tests/unit_python/test_configuration.py21
2 files changed, 12 insertions, 15 deletions
diff --git a/python_moonutilities/tests/unit_python/mock_repo/urls.py b/python_moonutilities/tests/unit_python/mock_repo/urls.py
index a5b1e63b..75b55927 100644
--- a/python_moonutilities/tests/unit_python/mock_repo/urls.py
+++ b/python_moonutilities/tests/unit_python/mock_repo/urls.py
@@ -9,11 +9,11 @@ def register_components(m):
json=[{'Key': component, 'Value': comp_util.get_b64_conf(component)}]
)
m.register_uri(
- 'GET', 'http://consul:8500/v1/kv/components_port_start',
- json=[{'Key': 'components_port_start', 'Value': comp_util.get_b64_conf("components/port_start")}]
+ 'GET', 'http://consul:8500/v1/kv/components/port_start',
+ json=[{'Key': 'port_start', 'Value': comp_util.get_b64_conf("components/port_start")}]
)
m.register_uri(
- 'PUT', 'http://consul:8500/v1/kv/components_port_start',
+ 'PUT', 'http://consul:8500/v1/kv/components/port_start',
json=[]
)
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()