summaryrefslogtreecommitdiffstats
path: root/dcae-cli/dcae_cli/catalog/mock
diff options
context:
space:
mode:
Diffstat (limited to 'dcae-cli/dcae_cli/catalog/mock')
-rw-r--r--dcae-cli/dcae_cli/catalog/mock/schema.py8
-rw-r--r--dcae-cli/dcae_cli/catalog/mock/tests/test_mock_catalog.py18
-rw-r--r--dcae-cli/dcae_cli/catalog/mock/tests/test_schema.py10
3 files changed, 17 insertions, 19 deletions
diff --git a/dcae-cli/dcae_cli/catalog/mock/schema.py b/dcae-cli/dcae_cli/catalog/mock/schema.py
index a27346b..640d125 100644
--- a/dcae-cli/dcae_cli/catalog/mock/schema.py
+++ b/dcae-cli/dcae_cli/catalog/mock/schema.py
@@ -1,7 +1,7 @@
# ============LICENSE_START=======================================================
# org.onap.dcae
# ================================================================================
-# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2018 AT&T Intellectual Property. 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.
@@ -110,8 +110,6 @@ def _validate(fetch_schema_func, schema_path, spec):
_validate_using_nexus = partial(_validate, _fetch_schema)
-_path_component_spec = cli_config.get_path_component_spec()
-
def apply_defaults(properties_definition, properties):
"""Utility method to enforce expected defaults
@@ -159,7 +157,7 @@ def apply_defaults_docker_config(config):
"""
# Apply health check defaults
healthcheck_type = config["healthcheck"]["type"]
- component_spec = _fetch_schema(_path_component_spec)
+ component_spec = _fetch_schema(cli_config.get_path_component_spec())
if healthcheck_type in ["http", "https"]:
apply_defaults_func = partial(apply_defaults,
@@ -176,7 +174,7 @@ def apply_defaults_docker_config(config):
return config
def validate_component(spec):
- _validate_using_nexus(_path_component_spec, spec)
+ _validate_using_nexus(cli_config.get_path_component_spec(), spec)
# REVIEW: Could not determine how to do this nicely in json schema. This is
# not ideal. We want json schema to be the "it" for validation.
diff --git a/dcae-cli/dcae_cli/catalog/mock/tests/test_mock_catalog.py b/dcae-cli/dcae_cli/catalog/mock/tests/test_mock_catalog.py
index 0c0a4e8..75b883d 100644
--- a/dcae-cli/dcae_cli/catalog/mock/tests/test_mock_catalog.py
+++ b/dcae-cli/dcae_cli/catalog/mock/tests/test_mock_catalog.py
@@ -1,7 +1,7 @@
# ============LICENSE_START=======================================================
# org.onap.dcae
# ================================================================================
-# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2018 AT&T Intellectual Property. 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.
@@ -277,7 +277,7 @@ _cdap_spec={
}
-def test_component_basic(catalog=None):
+def test_component_basic(mock_cli_config, catalog=None):
'''Tests basic component usage of MockCatalog'''
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True, enforce_image=False)
@@ -312,7 +312,7 @@ def test_component_basic(catalog=None):
assert cver == '1.0.0'
-def test_format_basic(catalog=None):
+def test_format_basic(mock_cli_config, catalog=None):
'''Tests basic data format usage of MockCatalog'''
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True)
@@ -351,7 +351,7 @@ def test_format_basic(catalog=None):
assert spec['self']['description'] == new_descr
-def test_discovery(catalog=None):
+def test_discovery(mock_cli_config, catalog=None):
'''Tests creation of discovery objects'''
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True, enforce_image=False)
@@ -393,7 +393,7 @@ def _format_tuple_set(*dds):
return set(map(_format_tuple, dds))
-def test_comp_list(catalog=None):
+def test_comp_list(mock_cli_config, catalog=None):
'''Tests the list functionality of the catalog'''
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True, enforce_image=False)
@@ -479,7 +479,7 @@ def test_comp_list(catalog=None):
assert len(components) == 4
-def test_format_list(catalog=None):
+def test_format_list(mock_cli_config, catalog=None):
'''Tests the list functionality of the catalog'''
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True, enforce_image=False)
@@ -523,7 +523,7 @@ def test_format_list(catalog=None):
assert len(formats) == 2
-def test_component_add_cdap(catalog=None):
+def test_component_add_cdap(mock_cli_config, catalog=None):
'''Adds a mock CDAP application'''
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True)
@@ -548,7 +548,7 @@ def test_component_add_cdap(catalog=None):
assert _cdap_spec == spec_out
-def test_get_discovery_from_spec():
+def test_get_discovery_from_spec(mock_cli_config):
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True,
enforce_image=False)
@@ -635,7 +635,7 @@ def test_get_discovery_from_spec():
assert actual_dmaap_config_keys == ([], [])
-def test_get_unpublished_formats(catalog=None):
+def test_get_unpublished_formats(mock_cli_config, catalog=None):
if catalog is None:
mc = MockCatalog(db_name='dcae_cli.test.db', purge_existing=True, enforce_image=False)
else:
diff --git a/dcae-cli/dcae_cli/catalog/mock/tests/test_schema.py b/dcae-cli/dcae_cli/catalog/mock/tests/test_schema.py
index 67fe9bf..1ac176b 100644
--- a/dcae-cli/dcae_cli/catalog/mock/tests/test_schema.py
+++ b/dcae-cli/dcae_cli/catalog/mock/tests/test_schema.py
@@ -1,7 +1,7 @@
# ============LICENSE_START=======================================================
# org.onap.dcae
# ================================================================================
-# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2018 AT&T Intellectual Property. 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.
@@ -209,7 +209,7 @@ cdap_component_test = r'''
'''
-def test_basic():
+def test_basic(mock_cli_config):
validate_component(json.loads(component_test))
validate_format(json.loads(format_test))
validate_component(json.loads(cdap_component_test))
@@ -232,7 +232,7 @@ def test_basic():
-def test_validate_docker_config():
+def test_validate_docker_config(mock_cli_config):
def compose_spec(config):
spec = json.loads(component_test)
@@ -282,7 +282,7 @@ def test_validate_docker_config():
validate_component(spec)
-def test_validate_cdap_config():
+def test_validate_cdap_config(mock_cli_config):
def compose_spec(config):
spec = json.loads(cdap_component_test)
@@ -350,7 +350,7 @@ def test_apply_defaults():
'location': {'lat': '40', 'long': '75'}}
-def test_apply_defaults_docker_config():
+def test_apply_defaults_docker_config(mock_cli_config):
# Test: Adding of missing expected properties for http
dc = { "healthcheck": { "type": "http", "endpoint": "/foo" } }
actual = apply_defaults_docker_config(dc)