aboutsummaryrefslogtreecommitdiffstats
path: root/python_moonutilities
diff options
context:
space:
mode:
Diffstat (limited to 'python_moonutilities')
-rw-r--r--python_moonutilities/Changelog4
-rw-r--r--python_moonutilities/python_moonutilities/__init__.py2
-rw-r--r--python_moonutilities/python_moonutilities/configuration.py5
-rw-r--r--python_moonutilities/python_moonutilities/exceptions.py35
-rw-r--r--python_moonutilities/tests/unit_python/mock_repo/urls.py5
-rw-r--r--python_moonutilities/tests/unit_python/test_configuration.py10
6 files changed, 54 insertions, 7 deletions
diff --git a/python_moonutilities/Changelog b/python_moonutilities/Changelog
index 2c4c02a8..ffc03809 100644
--- a/python_moonutilities/Changelog
+++ b/python_moonutilities/Changelog
@@ -78,3 +78,7 @@ CHANGES
1.4.5
-----
- Add PdpKeystoneMappingConflict exception
+
+1.4.6
+-----
+- Add WrapperConflict, PipelineConflict, SlaveNameUnknown exceptions
diff --git a/python_moonutilities/python_moonutilities/__init__.py b/python_moonutilities/python_moonutilities/__init__.py
index bcd7e545..741ba4f6 100644
--- a/python_moonutilities/python_moonutilities/__init__.py
+++ b/python_moonutilities/python_moonutilities/__init__.py
@@ -3,6 +3,6 @@
# license which can be found in the file 'LICENSE' in this package distribution
# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
-__version__ = "1.4.5"
+__version__ = "1.4.6"
diff --git a/python_moonutilities/python_moonutilities/configuration.py b/python_moonutilities/python_moonutilities/configuration.py
index 4a072de4..0516274c 100644
--- a/python_moonutilities/python_moonutilities/configuration.py
+++ b/python_moonutilities/python_moonutilities/configuration.py
@@ -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
diff --git a/python_moonutilities/python_moonutilities/exceptions.py b/python_moonutilities/python_moonutilities/exceptions.py
index 6db7bf01..1298f9e4 100644
--- a/python_moonutilities/python_moonutilities/exceptions.py
+++ b/python_moonutilities/python_moonutilities/exceptions.py
@@ -535,6 +535,41 @@ class ContainerMissing(DockerError):
logger = "ERROR"
+class WrapperConflict(MoonError):
+ description = _("A Wrapper already exist for the specified slave.")
+ code = 409
+ title = 'Wrapper conflict'
+ logger = "ERROR"
+
+
+class PipelineConflict(MoonError):
+ description = _("A Pipeline already exist for the specified slave.")
+ code = 409
+ title = 'Pipeline conflict'
+ logger = "ERROR"
+
+
+class PipelineUnknown(MoonError):
+ description = _("This Pipeline is unknown from the system.")
+ code = 400
+ title = 'Pipeline Unknown'
+ logger = "ERROR"
+
+
+class WrapperUnknown(MoonError):
+ description = _("This Wrapper is unknown from the system.")
+ code = 400
+ title = 'Wrapper Unknown'
+ logger = "ERROR"
+
+
+class SlaveNameUnknown(MoonError):
+ description = _("The slave is unknown.")
+ code = 400
+ title = 'Slave Unknown'
+ logger = "Error"
+
+
class PdpUnknown(MoonError):
description = _("The pdp is unknown.")
code = 400
diff --git a/python_moonutilities/tests/unit_python/mock_repo/urls.py b/python_moonutilities/tests/unit_python/mock_repo/urls.py
index 634f07b1..41fd1eec 100644
--- a/python_moonutilities/tests/unit_python/mock_repo/urls.py
+++ b/python_moonutilities/tests/unit_python/mock_repo/urls.py
@@ -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=[]
diff --git a/python_moonutilities/tests/unit_python/test_configuration.py b/python_moonutilities/tests/unit_python/test_configuration.py
index 5267179e..d5d83f7a 100644
--- a/python_moonutilities/tests/unit_python/test_configuration.py
+++ b/python_moonutilities/tests/unit_python/test_configuration.py
@@ -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