From 0a7c213c87d9b0916080d62d8e97ac4d47851688 Mon Sep 17 00:00:00 2001 From: Michal Jagiello Date: Tue, 12 Jul 2022 09:52:01 +0000 Subject: [CPS] Create CPS resources using data provider Create: - dataspace - anchor - schema set Issue-ID: INT-2135 Signed-off-by: Michal Jagiello Change-Id: I49fa9aa34bd4157372571275774c6a410d1bedcb --- onap_data_provider/resources/cps_resource.py | 188 +++++++++++++++++++++++ onap_data_provider/resources/resource_creator.py | 13 ++ onap_data_provider/schemas/infra_1_1.schema | 78 ++++++++++ samples/cps-bookstore.yang | 61 ++++++++ samples/cps.yaml | 22 +++ tests/test_aai_service_resource.py | 15 ++ tests/test_cloud_region_resource.py | 15 ++ tests/test_complex_resource.py | 15 ++ tests/test_config_loader.py | 14 ++ tests/test_config_parser.py | 15 ++ tests/test_cps_resource.py | 164 ++++++++++++++++++++ tests/test_customer_resource.py | 15 ++ tests/test_data_dictionary_resource.py | 17 +- tests/test_esr_resource.py | 15 ++ tests/test_line_of_business_resource.py | 15 ++ tests/test_owning_entity_resource.py | 15 ++ tests/test_platform_resource.py | 15 ++ tests/test_pnf_resource.py | 15 ++ tests/test_project_resource.py | 15 ++ tests/test_resource_creator.py | 15 ++ tests/test_service_instance_resource.py | 15 ++ tests/test_service_resource.py | 15 ++ tests/test_tag_handlers.py | 15 ++ tests/test_tenant_resource.py | 15 ++ tests/test_validator.py | 15 ++ tests/test_vendor_resource.py | 15 ++ tests/test_versions.py | 15 ++ tests/test_vnf_resource.py | 15 ++ tests/test_vsp_resource.py | 15 ++ tox.ini | 2 +- 30 files changed, 872 insertions(+), 2 deletions(-) create mode 100644 onap_data_provider/resources/cps_resource.py create mode 100644 samples/cps-bookstore.yang create mode 100644 samples/cps.yaml create mode 100644 tests/test_cps_resource.py diff --git a/onap_data_provider/resources/cps_resource.py b/onap_data_provider/resources/cps_resource.py new file mode 100644 index 0000000..c8e666f --- /dev/null +++ b/onap_data_provider/resources/cps_resource.py @@ -0,0 +1,188 @@ +"""CPS resources module.""" +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" + +import logging +from abc import ABC +from typing import Any, Dict + +from onapsdk.cps import Anchor, Dataspace, SchemaSet # type: ignore +from onapsdk.exceptions import APIError, ResourceNotFound # type: ignore + +from onap_data_provider.resources.resource import Resource + + +class DataspaceSubresource(Resource, ABC): + """Abstract dataspace subresource class.""" + + def __init__(self, data: Dict[str, Any]) -> None: + """Initialize dataspace subresource""" + super().__init__(data) + + self._dataspace: Dataspace = None + self._schema_set: SchemaSet = None + + @property + def dataspace(self) -> Dataspace: + """Dataspace property. + + Return dataspace object by it name. + + Returns: + Dataspace: Dataspace object. + + """ + return Dataspace(self.data["dataspace-name"]) + + @property + def schema_set(self) -> SchemaSet: + """Schema set property. + + Raises: + ValueError: Dataspace which name was used to get schema-set object doesn't exist + + Returns: + SchemaSet: Schema set object + + """ + if not self._schema_set: + try: + self._schema_set = self.dataspace.get_schema_set(self.data["schema-set-name"]) + except APIError as api_error: + # Needs to be fixed when https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/issues/181 is done + if "Dataspace not found" in str(api_error): + logging.error("Dataspace %s does not exist, create it before", self.data["dataspace-name"]) + raise ValueError("Dataspace %s does not exist, create it before", self.data["dataspace-name"]) + elif "Schema Set not found" in str(api_error): + logging.info("Schema set %s not found", self.data["schema-set-name"]) + return None + else: + raise + return self._schema_set + + +class AnchorResource(DataspaceSubresource): + """Anchor resource class + + Creates CPS anchor + """ + + def __init__(self, data: Dict[str, Any]) -> None: + """Initialize anchor resource""" + super().__init__(data) + + self._anchor: Anchor = None + + def create(self) -> None: + """Create anchor. + + Raises: + ValueError: Schema set doesn't exist + + """ + if not self.schema_set: + raise ValueError("Schema set %s does not exist, create it first", self.data["schema-set-name"]) + if not self.anchor: + self.dataspace.create_anchor(self.schema_set, self.data["anchor-name"]) + + @property + def anchor(self) -> Anchor: + """Anchor property. + + Tries to get anchor from dataspace. + + Returns: + Anchor: Anchor object, if anchor already exists. None otherwise. + + """ + if not self._anchor: + try: + self._anchor = self.dataspace.get_anchor(self.data["anchor-name"]) + except APIError as api_error: + if "Anchor not found" in str(api_error): + return None + else: + raise + return self._anchor + + +class SchemaSetResource(DataspaceSubresource): + """Schema set resource class + + Creates CPS schema set and + """ + + def __init__(self, data: Dict[str, Any]) -> None: + """Initialize schema set resource""" + super().__init__(data) + + def create(self) -> None: + """Create schema set resource.""" + if not self.schema_set: + with open(self.data["schema-set-file"], "rb") as schema_set_file: + self.dataspace.create_schema_set(self.data["schema-set-name"], schema_set_file) + + +class DataspaceResource(Resource): + """DataspaceResource resource class + + Creates CPS dataspace and sub-resources + """ + + def __init__(self, data: Dict[str, Any]) -> None: + """Initialize dataspace resource""" + super().__init__(data) + + self._dataspace: Dataspace = None + + def create(self) -> None: + try: + self._dataspace = Dataspace.create(self.data["dataspace-name"]) + except APIError as api_error: + # Needs to be fixed when https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/issues/181 is done + if "409" in str(api_error): + logging.warning("Dataspace %s already exists", self.data["dataspace-name"]) + self._dataspace = Dataspace(self.data["dataspace-name"]) + else: + raise + + for schema_set_data in self.data.get("schema-sets", []): + try: + self._dataspace.get_schema_set(schema_set_data["schema-set-name"]) + except APIError: + # Needs to be fixed when https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/issues/181 is done + with open(schema_set_data["schema-set-file"], "rb") as schema_set_file: + self._dataspace.create_schema_set( + schema_set_data["schema-set-name"], + schema_set_file + ) + else: + logging.warning("Schema set %s already exists", schema_set_data["schema-set-name"]) + + for anchor_data in self.data.get("anchors", []): + try: + self._dataspace.get_anchor(anchor_data["anchor-name"]) + except APIError: + try: + schema_set: SchemaSet = self._dataspace.get_schema_set(anchor_data["schema-set-name"]) + except APIError: + logging.warning("Schema set %s does not exist, anchor won't be created", + anchor_data["schema-set-name"]) + continue + self._dataspace.create_anchor(schema_set, + anchor_data["anchor-name"]) + else: + logging.warning("Anchor %s already exists", anchor_data["anchor-name"]) diff --git a/onap_data_provider/resources/resource_creator.py b/onap_data_provider/resources/resource_creator.py index c6ed4d8..7bd61bc 100644 --- a/onap_data_provider/resources/resource_creator.py +++ b/onap_data_provider/resources/resource_creator.py @@ -28,6 +28,7 @@ from .cloud_region_resource import CloudRegionResource from .complex_resource import ComplexResource from .customer_resource import CustomerResource from .data_dictionary_resource import DataDictionarySetResource +from .cps_resource import AnchorResource, DataspaceResource, SchemaSetResource from .line_of_business_resource import LineOfBusinessResource from .msb_k8s_definition import MsbK8SDefinitionResource from .owning_entity_resource import OwningEntityResource @@ -141,6 +142,15 @@ class ResourceCreator(ABC): }, "blueprint-resource-template": { VersionsEnum.V1_1: BlueprintResourceTemplateResource, + }, + "cps-dataspace": { + VersionsEnum.V1_1: DataspaceResource + }, + "cps-schema-set": { + VersionsEnum.V1_1: SchemaSetResource + }, + "cps-anchor": { + VersionsEnum.V1_1: AnchorResource } } @@ -174,6 +184,9 @@ class ResourceCreator(ABC): - data-dictionaries: DataDictionarySetResource - blueprints: BlueprintResource - blueprint-resource-template: BlueprintResourceTemplateResource + - cps-dataspace: DataspaceResource + - cps-schema-set: SchemaSetResource + - cps-anchor: AnchorResource Args: resource_type (str): Resource type to create diff --git a/onap_data_provider/schemas/infra_1_1.schema b/onap_data_provider/schemas/infra_1_1.schema index 9135569..d2480c6 100644 --- a/onap_data_provider/schemas/infra_1_1.schema +++ b/onap_data_provider/schemas/infra_1_1.schema @@ -677,3 +677,81 @@ properties: - resource-type - resource-id - data-file + cps-dataspaces: + type: array + items: + - type: object + properties: + cps-dataspace: + type: object + properties: + dataspace-name: + type: string + schema-sets: + type: array + items: + - type: object + properties: + schema-set-name: + type: string + schema-set-file: + type: string + required: + - schema-set-name + - schema-set-file + anchors: + type: array + items: + - type: object + properties: + anchor-name: + type: string + schema-set-name: + type: string + required: + - anchor-name + - schema-set-name + required: + - dataspace-name + required: + - cps-dataspace + cps-schema-sets: + type: array + items: + - type: object + properties: + cps-schema-set: + type: object + properties: + schema-set-name: + type: string + schema-set-file: + type: string + dataspace-name: + type: string + required: + - schema-set-name + - schema-set-file + - dataspace-name + required: + - cps-schema-set + cps-anchors: + type: array + items: + - type: object + properties: + cps-anchor: + type: object + properties: + anchor-name: + type: string + dataspace-name: + type: string + schema-set-name: + type: string + required: + - anchor-name + - dataspace-name + - schema-set-name + required: + - cps-anchor diff --git a/samples/cps-bookstore.yang b/samples/cps-bookstore.yang new file mode 100644 index 0000000..0bfbfb7 --- /dev/null +++ b/samples/cps-bookstore.yang @@ -0,0 +1,61 @@ +module stores { + yang-version 1.1; + namespace "org:onap:ccsdk:sample"; + + prefix book-store; + + revision "2020-09-15" { + description + "Sample Model"; + } + container shops { + + container bookstore { + + leaf bookstore-name { + type string; + } + + leaf name { + type string; + } + + list categories { + + key "code"; + + leaf code { + type uint16; + } + + leaf name { + type string; + } + + leaf numberOfBooks { + type uint16; + } + + container books { + + list book { + key title; + + leaf title { + type string; + } + leaf price { + type uint16; + } + leaf-list label { + type string; + } + leaf-list edition { + type string; + } + } + } + } + } + } +} \ No newline at end of file diff --git a/samples/cps.yaml b/samples/cps.yaml new file mode 100644 index 0000000..4c06fa6 --- /dev/null +++ b/samples/cps.yaml @@ -0,0 +1,22 @@ +# CPS Sample +odpSchemaVersion: 1.1 +resources: + cps-dataspaces: + - cps-dataspace: + dataspace-name: test-odp-dataspace + schema-sets: + - schema-set-name: &schema-set-name test-odp-schema-set + schema-set-file: samples/cps-bookstore.yang + anchors: + - anchor-name: test-odp-anchor + schema-set-name: *schema-set-name + cps-schema-sets: + - cps-schema-set: + schema-set-name: test-odp-schemaset + dataspace-name: test-odp-dataspace + schema-set-file: samples/cps-bookstore.yang + cps-anchors: + - cps-anchor: + anchor-name: test-odp-anchor + schema-set-name: test-odp-schemaset + dataspace-name: test-odp-dataspace diff --git a/tests/test_aai_service_resource.py b/tests/test_aai_service_resource.py index 9056299..22af4ef 100644 --- a/tests/test_aai_service_resource.py +++ b/tests/test_aai_service_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import patch, PropertyMock from onap_data_provider.resources.aai_service_resource import AaiService, AaiServiceResource, ResourceNotFound diff --git a/tests/test_cloud_region_resource.py b/tests/test_cloud_region_resource.py index 303e1c3..e9e4974 100644 --- a/tests/test_cloud_region_resource.py +++ b/tests/test_cloud_region_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from pathlib import Path from unittest.mock import MagicMock, patch, PropertyMock diff --git a/tests/test_complex_resource.py b/tests/test_complex_resource.py index 441b37c..3c84620 100644 --- a/tests/test_complex_resource.py +++ b/tests/test_complex_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import patch, PropertyMock from onapsdk.aai.cloud_infrastructure.complex import Complex diff --git a/tests/test_config_loader.py b/tests/test_config_loader.py index c10e329..5574e09 100644 --- a/tests/test_config_loader.py +++ b/tests/test_config_loader.py @@ -1,4 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from pathlib import Path from onap_data_provider.config_loader import ConfigLoader diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index dc118c9..d7eaa4d 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from pathlib import Path from onap_data_provider.resources.cloud_region_resource import CloudRegionResource diff --git a/tests/test_cps_resource.py b/tests/test_cps_resource.py new file mode 100644 index 0000000..2e01ad6 --- /dev/null +++ b/tests/test_cps_resource.py @@ -0,0 +1,164 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" +from unittest.mock import MagicMock, NonCallableMagicMock, patch, PropertyMock + +from onapsdk.exceptions import APIError, ResourceNotFound +from pytest import raises + +from onap_data_provider.resources.cps_resource import AnchorResource, DataspaceResource, SchemaSetResource + + +DATASPACE_RESOURCE_DATA = { + "dataspace-name": "test-dataspace-resource", +} + +DATASPACE_WITH_SCHEMASETS_DATA = { + "dataspace-name": "test-dataspace-resource", + "schema-sets": [ + { + "schema-set-name": "test-schema-set", + "schema-set-file": "test-schema-set-file" + } + ] +} + +DATASPACE_WITH_ANCHORS_DATA = { + "dataspace-name": "test-dataspace-resource", + "anchors": [ + { + "anchor-name": "test-anchor", + "schema-set-name": "test-schema-set" + } + ] +} + +SCHEMA_SET_DATA = { + "schema-set-name": "test-schema-set", + "dataspace-name": "test-dataspace", + "schema-set-file": "test-schema-set-file" +} + +ANCHOR_DATA = { + "anchor-name": "test-anchor", + "dataspace-name": "test-dataspace", + "schema-set-name": "test-schema-set" +} + + +@patch("onap_data_provider.resources.cps_resource.Dataspace") +def test_dataspace_resource_create(mock_dataspace): + dr = DataspaceResource(DATASPACE_RESOURCE_DATA) + dr.create() + mock_dataspace.create.assert_called_once_with("test-dataspace-resource") + mock_dataspace.assert_not_called() + + mock_dataspace.reset_mock() + mock_dataspace.create.side_effect = APIError("409 error") + dr.create() + mock_dataspace.create.assert_called_once_with("test-dataspace-resource") + mock_dataspace.assert_called_once_with("test-dataspace-resource") + + mock_dataspace.reset_mock() + mock_dataspace.create.side_effect = APIError("404") + with raises(APIError): + dr.create() + +@patch("onap_data_provider.resources.cps_resource.Dataspace") +def test_dataspace_resource_with_schemasets(mock_dataspace): + dr = DataspaceResource(DATASPACE_WITH_SCHEMASETS_DATA) + dr.create() + mock_dataspace.create.assert_called_once_with("test-dataspace-resource") + mock_dataspace.create.return_value.get_schema_set.assert_called_once_with("test-schema-set") + mock_dataspace.create.return_value.create_schema_set.assert_not_called() + + mock_dataspace.reset_mock() + mock_dataspace.create.return_value.get_schema_set.side_effect = APIError("409 error") + with patch("builtins.open") as mock_open: + dr.create() + mock_dataspace.create.assert_called_once_with("test-dataspace-resource") + mock_dataspace.create.return_value.get_schema_set.assert_called_once_with("test-schema-set") + mock_dataspace.create.return_value.create_schema_set.assert_called_once() + mock_open.assert_called_once_with("test-schema-set-file", "rb") + +@patch("onap_data_provider.resources.cps_resource.Dataspace") +def test_dataspace_resource_with_anchors(mock_dataspace): + dr = DataspaceResource(DATASPACE_WITH_ANCHORS_DATA) + dr.create() + mock_dataspace.create.assert_called_once_with("test-dataspace-resource") + mock_dataspace.create.return_value.get_anchor.assert_called_once_with("test-anchor") + mock_dataspace.create.return_value.create_anchor.assert_not_called() + + mock_dataspace.reset_mock() + mock_dataspace.create.return_value.get_anchor.side_effect = APIError("409 error") + dr.create() + mock_dataspace.create.assert_called_once_with("test-dataspace-resource") + mock_dataspace.create.return_value.get_anchor.assert_called_once_with("test-anchor") + mock_dataspace.create.return_value.get_schema_set.assert_called_once_with("test-schema-set") + mock_dataspace.create.return_value.create_anchor.assert_called_once() + +@patch("onap_data_provider.resources.cps_resource.SchemaSetResource.dataspace", new_callable=PropertyMock) +def test_schema_set_schema_set_property(mock_dataspace_property): + ssr = SchemaSetResource(SCHEMA_SET_DATA) + + mock_dataspace_property.return_value.get_schema_set.side_effect = APIError("Dataspace not found") + with raises(ValueError): + ssr.schema_set + + mock_dataspace_property.return_value.get_schema_set.side_effect = APIError("Schema Set not found") + assert ssr.schema_set is None + + mock_dataspace_property.return_value.get_schema_set.side_effect = None + assert ssr.schema_set is not None + +@patch("onap_data_provider.resources.cps_resource.SchemaSetResource.schema_set", new_callable=PropertyMock) +@patch("onap_data_provider.resources.cps_resource.SchemaSetResource.dataspace", new_callable=PropertyMock) +def test_schema_set_resource(mock_dataspace_property, mock_schema_set_property): + ssr = SchemaSetResource(SCHEMA_SET_DATA) + + mock_schema_set_property.side_effect = ValueError + with raises(ValueError): + ssr.create() + + mock_schema_set_property.side_effect = None + + with patch("builtins.open"): + ssr.create() + mock_dataspace_property.return_value.create_schema_set.assert_not_called() + + mock_schema_set_property.return_value = None + with patch("builtins.open"): + ssr.create() + mock_dataspace_property.return_value.create_schema_set.assert_called_once() + +@patch("onap_data_provider.resources.cps_resource.AnchorResource.schema_set", new_callable=PropertyMock) +@patch("onap_data_provider.resources.cps_resource.AnchorResource.dataspace", new_callable=PropertyMock) +def test_anchor_resource(mock_dataspace_property, mock_schema_set_property): + ar = AnchorResource(ANCHOR_DATA) + + mock_schema_set_property.side_effect = ValueError + with raises(ValueError): + ar.create() + + mock_schema_set_property.side_effect = None + mock_schema_set_property.return_value = None + with raises(ValueError): + ar.create() + + mock_schema_set_property.side_effect = None + mock_schema_set_property.return_value = MagicMock() + ar.create() + mock_dataspace_property.return_value.get_anchor.assert_called_once_with("test-anchor") + mock_dataspace_property.return_value.create_anchor.assert_not_called() diff --git a/tests/test_customer_resource.py b/tests/test_customer_resource.py index 23b51ef..c82b016 100644 --- a/tests/test_customer_resource.py +++ b/tests/test_customer_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import MagicMock, patch, PropertyMock from onap_data_provider.resources.customer_resource import CustomerResource diff --git a/tests/test_data_dictionary_resource.py b/tests/test_data_dictionary_resource.py index 31369f7..b9ea2fe 100644 --- a/tests/test_data_dictionary_resource.py +++ b/tests/test_data_dictionary_resource.py @@ -1,4 +1,19 @@ -from unittest.mock import patch, PropertyMock +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" +from unittest.mock import patch from onapsdk.cds import DataDictionarySet from onapsdk.exceptions import FileError diff --git a/tests/test_esr_resource.py b/tests/test_esr_resource.py index d6c8901..0339d2b 100644 --- a/tests/test_esr_resource.py +++ b/tests/test_esr_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from collections import namedtuple from unittest.mock import MagicMock, patch, PropertyMock diff --git a/tests/test_line_of_business_resource.py b/tests/test_line_of_business_resource.py index 1a60e8f..3867a3f 100644 --- a/tests/test_line_of_business_resource.py +++ b/tests/test_line_of_business_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest import mock from onap_data_provider.resources.line_of_business_resource import ( diff --git a/tests/test_owning_entity_resource.py b/tests/test_owning_entity_resource.py index c32351c..af6c299 100644 --- a/tests/test_owning_entity_resource.py +++ b/tests/test_owning_entity_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest import mock from onap_data_provider.resources.owning_entity_resource import ( diff --git a/tests/test_platform_resource.py b/tests/test_platform_resource.py index eafbae4..642c32e 100644 --- a/tests/test_platform_resource.py +++ b/tests/test_platform_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest import mock from onap_data_provider.resources.platform_resource import ( diff --git a/tests/test_pnf_resource.py b/tests/test_pnf_resource.py index 62dc3ae..c13ca55 100644 --- a/tests/test_pnf_resource.py +++ b/tests/test_pnf_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import MagicMock, patch, PropertyMock from onap_data_provider.resources.pnf_resource import PnfResource diff --git a/tests/test_project_resource.py b/tests/test_project_resource.py index c1ff167..70e6cd1 100644 --- a/tests/test_project_resource.py +++ b/tests/test_project_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest import mock from onap_data_provider.resources.project_resource import ( diff --git a/tests/test_resource_creator.py b/tests/test_resource_creator.py index a8e62ed..156dd94 100644 --- a/tests/test_resource_creator.py +++ b/tests/test_resource_creator.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" import pytest from onap_data_provider.resources.cloud_region_resource import CloudRegionResource diff --git a/tests/test_service_instance_resource.py b/tests/test_service_instance_resource.py index 91e8860..1fc2af8 100644 --- a/tests/test_service_instance_resource.py +++ b/tests/test_service_instance_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import MagicMock, patch, PropertyMock from onap_data_provider.resources.service_instance_resource import ( diff --git a/tests/test_service_resource.py b/tests/test_service_resource.py index 5a18f54..3f85f54 100644 --- a/tests/test_service_resource.py +++ b/tests/test_service_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from collections import namedtuple from unittest.mock import patch, PropertyMock diff --git a/tests/test_tag_handlers.py b/tests/test_tag_handlers.py index c7c9ffc..d52626d 100644 --- a/tests/test_tag_handlers.py +++ b/tests/test_tag_handlers.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import patch, PropertyMock import pytest diff --git a/tests/test_tenant_resource.py b/tests/test_tenant_resource.py index 2c89651..1e9da31 100644 --- a/tests/test_tenant_resource.py +++ b/tests/test_tenant_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import MagicMock, patch, PropertyMock from onap_data_provider.resources.tenant_resource import TenantResource diff --git a/tests/test_validator.py b/tests/test_validator.py index f0c7273..7da968d 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from pytest import raises from jsonschema import ValidationError diff --git a/tests/test_vendor_resource.py b/tests/test_vendor_resource.py index 2a4d0aa..b4d93dc 100644 --- a/tests/test_vendor_resource.py +++ b/tests/test_vendor_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import patch, PropertyMock from onap_data_provider.resources.vendor_resource import VendorResource diff --git a/tests/test_versions.py b/tests/test_versions.py index 7571854..1a8ce0c 100644 --- a/tests/test_versions.py +++ b/tests/test_versions.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" import warnings from onap_data_provider.versions import VersionsEnum diff --git a/tests/test_vnf_resource.py b/tests/test_vnf_resource.py index e35cded..72af516 100644 --- a/tests/test_vnf_resource.py +++ b/tests/test_vnf_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import MagicMock, patch, PropertyMock from onap_data_provider.resources.vnf_resource import VnfResource diff --git a/tests/test_vsp_resource.py b/tests/test_vsp_resource.py index 9ad5bb6..5e2db23 100644 --- a/tests/test_vsp_resource.py +++ b/tests/test_vsp_resource.py @@ -1,3 +1,18 @@ +""" + Copyright 2022 Deutsche Telekom AG + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from unittest.mock import patch, PropertyMock from onap_data_provider.resources.vsp_resource import VspResource diff --git a/tox.ini b/tox.ini index 1aa0572..ee753cf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.2.0 -envlist = json,yaml,py,rst,md,mypy +envlist = json,yaml,py,rst,md,mypy,cov skipsdist = true requires = pip >= 8 -- cgit 1.2.3-korg