adding tests for the change "interface - pipline" 27/50427/1
authorsgdt6900 <rhanafy.ext@orange.com>
Thu, 11 Jan 2018 14:14:59 +0000 (16:14 +0200)
committersgdt6900 <rhanafy.ext@orange.com>
Thu, 11 Jan 2018 14:14:59 +0000 (16:14 +0200)
Change-Id: I0f302ca240e03f43ffd47822b548721174c37a86
Signed-off-by: sgdt6900 <rhanafy.ext@orange.com>
python_moonutilities/python_moonutilities/configuration.py
python_moonutilities/tests/unit_python/mock_repo/urls.py
python_moonutilities/tests/unit_python/test_configuration.py

index 4a072de..0516274 100644 (file)
@@ -91,7 +91,10 @@ def get_plugins():
     pipeline = get_configuration("components/pipeline")
     logger.debug("pipeline={}".format(pipeline))
     components = pipeline.get("components/pipeline")
-    components.pop('interface')
+    if 'interface' in components:
+        components.pop('interface')
+    else:
+        raise exceptions.ConsulComponentContentError("error= Components pipeline has no interface")
     return components
 
 
index 634f07b..41fd1ee 100644 (file)
@@ -8,10 +8,7 @@ def register_components(m):
             'GET', 'http://consul:8500/v1/kv/{}'.format(component),
             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")}]
-    )
+
     m.register_uri(
         'PUT', 'http://consul:8500/v1/kv/components/port_start',
         json=[]
index 5267179..d5d83f7 100644 (file)
@@ -98,7 +98,15 @@ def test_get_plugins_success():
     plugin = configuration.get_plugins()
     assert plugin is not None
 
-
+def test_get_plugins_failure(no_requests):
+    from python_moonutilities import configuration
+    no_requests.register_uri(
+        'GET', 'http://consul:8500/v1/kv/components/pipeline',
+        json=[{'Key': 'components/pipeline', 'Value': 'eyJjb250YWluZXIiOiAid3Vrb25nc3VuL21vb25fYXV0aHo6djQuMyIsICJwb3J0IjogODA4MX0='}]
+    )
+    with pytest.raises(Exception) as exception_info:
+        configuration.get_plugins()
+    assert str(exception_info.value) == '500: Consul Content error'
 ################################ component ####################################
 def test_get_components():
     from python_moonutilities import configuration