diff options
author | 2020-05-19 09:52:46 -0700 | |
---|---|---|
committer | 2020-05-19 09:59:16 -0700 | |
commit | d481ad9918d383c82335e52db4a360964194ef5d (patch) | |
tree | f3174fa5bc95e340b908e3c854edf1af2e8119c9 /onap-client/onap_client/so | |
parent | e4fca937cc6104ff56c52f720d26552febe44bee (diff) |
[VVP] Updates to VVP test-engine
Removing module level variables. These can cause import errors if certain modules are not imported "properly". Removing these lets developers import modules as-needed.
Add support for VNF category. The VNF category is looked up based on the category chosen by the VSP.
Increase test coverage.
Update ovp testsuite based on these changes.
Issue-ID: VVP-418
Signed-off-by: stark, steven <steven.stark@att.com>
Change-Id: I074375b8afae1adff60e0730d6f8a69d01cdd475
Diffstat (limited to 'onap-client/onap_client/so')
-rw-r--r-- | onap-client/onap_client/so/module_instance.py | 15 | ||||
-rw-r--r-- | onap-client/onap_client/so/service_instance.py | 36 | ||||
-rw-r--r-- | onap-client/onap_client/so/tests/base_preload.json | 37 | ||||
-rw-r--r-- | onap-client/onap_client/so/tests/test_module_instance.py | 227 | ||||
-rw-r--r-- | onap-client/onap_client/so/tests/test_service_instance.py | 136 | ||||
-rw-r--r-- | onap-client/onap_client/so/tests/test_vnf_instance.py | 174 |
6 files changed, 602 insertions, 23 deletions
diff --git a/onap-client/onap_client/so/module_instance.py b/onap-client/onap_client/so/module_instance.py index 19af17a..75105ed 100644 --- a/onap-client/onap_client/so/module_instance.py +++ b/onap-client/onap_client/so/module_instance.py @@ -37,17 +37,14 @@ import uuid from onap_client.resource import Resource -from onap_client.client.clients import Client as SOClient +from onap_client.client.clients import Client from onap_client.exceptions import ServiceInstanceNotFound, VNFInstanceNotFound, ModuleInstanceNotFound from onap_client import so from onap_client import sdnc from onap_client.util import utility -oc = SOClient() -so_client = oc.so - -class VNFInstance(Resource): +class ModuleInstance(Resource): resource_name = "MODULE_INSTANCE" spec = { "module_instance_name": {"type": str, "required": True}, @@ -180,6 +177,8 @@ class VNFInstance(Resource): def create_module_instance(instance_input): + oc = Client() + sdnc.preload.Preload( instance_input.get("preload_path"), instance_input.get("vnf_instance_name"), @@ -190,7 +189,7 @@ def create_module_instance(instance_input): ) headers = {"X-TransactionId": str(uuid.uuid4())} - module_instance = so_client.service_instantiation.create_module_instance( + module_instance = oc.so.service_instantiation.create_module_instance( **instance_input, **headers ) @@ -206,6 +205,8 @@ def create_module_instance(instance_input): @utility def delete_module_instance(service_instance_name, vnf_instance_name, module_instance_name, api_type="GR_API"): """Delete a Module Instance from SO""" + oc = Client() + si = so.service_instance.get_service_instance(service_instance_name) si_id = si.get("service-instance-id") for vnfi in si.get("service-data", {}).get("vnfs", {}).get("vnf", []): @@ -220,7 +221,7 @@ def delete_module_instance(service_instance_name, vnf_instance_name, module_inst tenant_id = modulei.get("vf-module-data").get("vf-module-request-input").get("tenant") cloud_owner = modulei.get("vf-module-data").get("vf-module-request-input").get("cloud-owner") cloud_region = modulei.get("vf-module-data").get("vf-module-request-input").get("aic-cloud-region") - return so_client.service_instantiation.delete_module_instance( + return oc.so.service_instantiation.delete_module_instance( module_invariant_id=module_invariant_id, module_name=module_name, module_version=module_version, diff --git a/onap-client/onap_client/so/service_instance.py b/onap-client/onap_client/so/service_instance.py index a5a2e8f..6398ac8 100644 --- a/onap-client/onap_client/so/service_instance.py +++ b/onap-client/onap_client/so/service_instance.py @@ -39,7 +39,7 @@ import uuid from onap_client.lib import generate_dummy_string from onap_client.resource import Resource -from onap_client.client.clients import Client as SOClient +from onap_client.client.clients import Client from onap_client.so import SO_PROPERTIES from onap_client.exceptions import ( SORequestStatusUnavailable, @@ -50,16 +50,8 @@ from onap_client.exceptions import ( ) from onap_client import sdc from onap_client.util import utility - from time import sleep -oc = SOClient() -so_client = oc.so -sdc_client = oc.sdc -aai_client = oc.aai -sdnc_client = oc.sdnc -vid_client = oc.vid - class ServiceInstance(Resource): resource_name = "SERVICE_INSTANCE" @@ -97,6 +89,8 @@ class ServiceInstance(Resource): project_name, owning_entity_name, ): + self.oc = Client() + instance_input = {} tenant_id = get_tenant_id(cloud_region, cloud_owner, tenant_name) @@ -117,7 +111,7 @@ class ServiceInstance(Resource): super().__init__(instance_input) def _create(self, instance_input): - service_model = sdc_client.service.get_sdc_service( + service_model = self.oc.sdc.service.get_sdc_service( catalog_service_id=sdc.service.get_service_id( instance_input.get("model_name") ) @@ -126,7 +120,7 @@ class ServiceInstance(Resource): instance_input["model_invariant_id"] = service_model["invariantUUID"] instance_input["model_version_id"] = service_model["uniqueId"] - category_parameters = vid_client.maintenance.get_category_parameters().response_data + category_parameters = self.oc.vid.maintenance.get_category_parameters().response_data for entity in category_parameters.get("categoryParameters", {}).get("owningEntity", []): if entity.get("name") == instance_input.get("owning_entity_name"): instance_input["owning_entity_id"] = entity.get("id") @@ -145,7 +139,9 @@ class ServiceInstance(Resource): def get_service_instance(instance_name): """Queries SDNC for a list of all service instances and returns The service instance that matches <instance name>""" - service_instances = sdnc_client.config.get_service_instances().response_data + oc = Client() + + service_instances = oc.sdnc.config.get_service_instances().response_data for si in service_instances.get("services", {}).get("service", []): if si.get("service-data", {}).get("service-request-input", {}).get("service-instance-name") == instance_name: return si @@ -154,7 +150,9 @@ def get_service_instance(instance_name): def get_tenant_id(cloud_region, cloud_owner, tenant_name): - tenants = aai_client.cloud_infrastructure.get_cloud_region_tenants( + oc = Client() + + tenants = oc.aai.cloud_infrastructure.get_cloud_region_tenants( cloud_owner=cloud_owner, cloud_region=cloud_region ).response_data @@ -167,8 +165,10 @@ def get_tenant_id(cloud_region, cloud_owner, tenant_name): def create_service_instance(instance_input): + oc = Client() + headers = {"X-TransactionId": str(uuid.uuid4())} - service_instance = so_client.service_instantiation.create_service_instance( + service_instance = oc.so.service_instantiation.create_service_instance( **instance_input, **headers ) @@ -184,11 +184,13 @@ def create_service_instance(instance_input): @utility def poll_request(request_id): """Poll an SO request until completion""" + oc = Client() + poll_interval = SO_PROPERTIES.POLL_INTERVAL or 30 request = None x = 0 while x < 30: - request = so_client.service_instantiation.get_request_status( + request = oc.so.service_instantiation.get_request_status( request_id=request_id ).response_data status = request.get("request", {}).get("requestStatus", {}).get("requestState") @@ -216,12 +218,14 @@ def poll_request(request_id): @utility def delete_service_instance(service_instance_name, api_type="GR_API"): """Delete a Service Instance from SO""" + oc = Client() + si = get_service_instance(service_instance_name) si_id = si.get("service-instance-id") invariant_id = si.get("service-data").get("service-information").get("onap-model-information").get("model-invariant-uuid") version = si.get("service-data").get("service-information").get("onap-model-information").get("model-version") - return so_client.service_instantiation.delete_service_instance( + return oc.so.service_instantiation.delete_service_instance( service_invariant_id=invariant_id, service_name=service_instance_name, service_version=version, diff --git a/onap-client/onap_client/so/tests/base_preload.json b/onap-client/onap_client/so/tests/base_preload.json new file mode 100644 index 0000000..e4876a6 --- /dev/null +++ b/onap-client/onap_client/so/tests/base_preload.json @@ -0,0 +1,37 @@ +{ + "input": { + "request-information": { + "request-id": "robot12", + "order-version": "1", + "notification-url": "openecomp.org", + "order-number": "1", + "request-action": "PreloadVfModuleRequest" + }, + "sdnc-request-header": { + "svc-request-id": "robot12", + "svc-notification-url": "http://openecomp.org:8080/adapters/rest/SDNCNotify", + "svc-action": "reserve" + }, + "preload-vf-module-topology-information": { + "vnf-topology-identifier-structure": { + "vnf-name": "", + "vnf-type": "" + }, + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [] + }, + "vnf-networks": {} + }, + "vf-module-topology": { + "vf-module-topology-identifier": { + "vf-module-type": "", + "vf-module-name": "" + }, + "vf-module-parameters": { + "param": [] + } + } + } + } +}
\ No newline at end of file diff --git a/onap-client/onap_client/so/tests/test_module_instance.py b/onap-client/onap_client/so/tests/test_module_instance.py new file mode 100644 index 0000000..297fdea --- /dev/null +++ b/onap-client/onap_client/so/tests/test_module_instance.py @@ -0,0 +1,227 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software 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. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# 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. +# +# ============LICENSE_END============================================ +import responses +from onap_client.client.clients import Client +from onap_client.tests.utils import mockup_catalog_item +from onap_client.so.module_instance import ModuleInstance +from os.path import dirname, abspath + +THIS_DIR = dirname(abspath(__file__)) + + +@responses.activate +def test_module_instance(): + oc = Client() + + SERVICE_MODEL_NAME = "service_model_name" + SERVICE_MODEL_ID = "service_model_id" + SERVICE_MODEL_INVARIANT_ID = "service_model_invariant_id" + SERVICE_INSTANCE_NAME = "service_instance_name" + SERVICE_INSTANCE_ID = "service_instance_id" + SERVICE_INSTANCE_INVARIANT_ID = "service_instance_invariant_id" + SERVICE_INSTANCE_VERSION = "service_instance_version" + SERVICE_INSTANCE_UUID = "service_instance_uuid" + + VNF_MODEL_NAME = "vnf_model_name" + VNF_INSTANCE_NAME = "vnf_instance_name" + VNF_INSTANCE_ID = "vnf_instance_id" + VNF_CUSTOMIZATION_UUID = "vnf_customization_uuid" + VNF_INVARIANT_ID = "vnf_invariant_id" + VNF_ACTUAL_UUID = "vnf_actual_uuid" + VNF_VERSION = "vnf_version" + + HEAT_TEMPLATE_NAME = "base.yaml" + HEAT_TEMPLATE_ARTIFACT_UUID = "heat_template_artifact_uuid" + + MODULE_MODEL_INVARIANT_UUID = "module_model_invariant_uuid" + MODULE_MODEL_VERSION_ID = "module_model_version_id" + MODULE_MODEL_CUSTOMIZATION_ID = "module_model_customization_id" + MODULE_MODEL_NAME = "module_model_name" + MODULE_MODEL_VERSION = "module_model_version" + + MODULE_INSTANCE_NAME = "module_instance_name" + + CLOUD_OWNER = "cloud_owner" + CLOUD_REGION = "cloud_region" + TENANT_NAME = "tenant_name" + TENANT_ID = "tenant_id" + REQUEST_ID = "request_id" + + mockup_catalog_item( + oc.sdc.service.catalog_items["GET_SERVICES"], + override_return_data={ + "services": [ + { + "name": SERVICE_MODEL_NAME, + "uniqueId": SERVICE_MODEL_ID, + "lastUpdateDate": 123456, + } + ] + }, + ) + mockup_catalog_item( + oc.aai.cloud_infrastructure.catalog_items["GET_CLOUD_REGION_TENANTS"], + override_uri_params={"cloud_owner": CLOUD_OWNER, "cloud_region": CLOUD_REGION}, + override_return_data={ + "tenant": [ + { + "tenant-name": TENANT_NAME, + "tenant-id": TENANT_ID + } + ], + } + ) + mockup_catalog_item( + oc.sdc.service.catalog_items["GET_SDC_SERVICE"], + override_uri_params={"catalog_service_id": SERVICE_MODEL_ID}, + override_return_data={ + "invariantUUID": SERVICE_MODEL_INVARIANT_ID, + "uniqueId": SERVICE_MODEL_ID, + "componentInstances": [ + { + "componentName": VNF_MODEL_NAME, + "customizationUUID": VNF_CUSTOMIZATION_UUID, + "actualComponentUid": VNF_ACTUAL_UUID, + "componentVersion": VNF_VERSION, + "deploymentArtifacts": { + "heat1": { + "artifactName": HEAT_TEMPLATE_NAME, + "artifactUUID": HEAT_TEMPLATE_ARTIFACT_UUID + } + }, + "groupInstances": [ + { + "artifactsUuid": [HEAT_TEMPLATE_ARTIFACT_UUID], + "invariantUUID": MODULE_MODEL_INVARIANT_UUID, + "groupUUID": MODULE_MODEL_VERSION_ID, + "customizationUUID": MODULE_MODEL_CUSTOMIZATION_ID, + "groupName": MODULE_MODEL_NAME, + "version": MODULE_MODEL_VERSION + } + ] + } + ] + } + ) + mockup_catalog_item( + oc.sdc.vnf.catalog_items["GET_CATALOG_RESOURCE"], + override_return_data={ + "invariantUUID": VNF_INVARIANT_ID + }, + override_uri_params={"catalog_resource_id": VNF_ACTUAL_UUID}, + ) + mockup_catalog_item( + oc.sdnc.operations.catalog_items["GR_API_PRELOAD"], + ) + mockup_catalog_item( + oc.sdnc.config.catalog_items["GET_SERVICE_INSTANCES"], + override_return_data={ + "services": { + "service": [ + { + "service-data": { + "service-request-input": { + "service-instance-name": SERVICE_INSTANCE_NAME + }, + "service-information": { + "onap-model-information": { + "model-invariant-uuid": SERVICE_INSTANCE_INVARIANT_ID, + "model-uuid": SERVICE_INSTANCE_UUID, + "model-version": SERVICE_INSTANCE_VERSION, + "model-name": SERVICE_MODEL_NAME, + } + }, + "vnfs": { + "vnf": [ + { + "vnf-data": { + "vnf-information": { + "vnf-name": VNF_INSTANCE_NAME, + "vnf-id": VNF_INSTANCE_ID, + "onap-model-information": { + "model-name": VNF_MODEL_NAME, + "model-invariant-uuid": VNF_INVARIANT_ID, + "model-uuid": VNF_ACTUAL_UUID, + "model-customization-uuid": VNF_CUSTOMIZATION_UUID, + "model-version": "1.0" + } + } + } + } + ] + } + }, + "service-instance-id": SERVICE_INSTANCE_ID + } + ] + } + }, + ) + mockup_catalog_item( + oc.so.service_instantiation.catalog_items["CREATE_MODULE_INSTANCE"], + override_return_data={ + "requestReferences": { + "requestId": REQUEST_ID + } + } + ) + mockup_catalog_item( + oc.so.service_instantiation.catalog_items["GET_REQUEST_STATUS"], + override_uri_params={"request_id": REQUEST_ID}, + override_return_data={ + "request": { + "requestStatus": { + "requestState": "COMPLETE" + } + } + } + ) + + mi = ModuleInstance( + MODULE_INSTANCE_NAME, + VNF_INSTANCE_NAME, + SERVICE_INSTANCE_NAME, + "cs0008", + HEAT_TEMPLATE_NAME, + "{}/base_preload.json".format(THIS_DIR), + TENANT_NAME, + CLOUD_OWNER, + CLOUD_REGION, + "GR_API" + ) + + assert mi.module_instance_name == MODULE_INSTANCE_NAME diff --git a/onap-client/onap_client/so/tests/test_service_instance.py b/onap-client/onap_client/so/tests/test_service_instance.py new file mode 100644 index 0000000..e0afccc --- /dev/null +++ b/onap-client/onap_client/so/tests/test_service_instance.py @@ -0,0 +1,136 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software 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. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# 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. +# +# ============LICENSE_END============================================ +import responses +from onap_client.client.clients import Client +from onap_client.tests.utils import mockup_catalog_item +from onap_client.so.service_instance import ServiceInstance + + +@responses.activate +def test_service_instance(): + oc = Client() + + SERVICE_MODEL_NAME = "service_model" + SERVICE_MODEL_ID = "service_model_id" + SERVICE_MODEL_INVARIANT_ID = "service_model_invariant_id" + SERVICE_INSTANCE_NAME = "SERVICE_INSTANCE_NAME" + OWNING_ENTITY_NAME = "owning_entity" + OWNING_ENTITY_ID = "owning_entity_id" + CLOUD_OWNER = "cloud_owner" + CLOUD_REGION = "cloud_region" + TENANT_NAME = "tenant_name" + TENANT_ID = "tenant_id" + REQUEST_ID = "request_id" + + mockup_catalog_item( + oc.sdc.service.catalog_items["GET_SERVICES"], + override_return_data={ + "services": [ + { + "name": SERVICE_MODEL_NAME, + "uniqueId": SERVICE_MODEL_ID, + "lastUpdateDate": 123456 + } + ] + }, + ) + mockup_catalog_item( + oc.sdc.service.catalog_items["GET_SDC_SERVICE"], + override_uri_params={"catalog_service_id": SERVICE_MODEL_ID}, + override_return_data={"invariantUUID": SERVICE_MODEL_INVARIANT_ID, "uniqueId": SERVICE_MODEL_ID} + ) + mockup_catalog_item( + oc.aai.cloud_infrastructure.catalog_items["GET_CLOUD_REGION_TENANTS"], + override_uri_params={"cloud_owner": CLOUD_OWNER, "cloud_region": CLOUD_REGION}, + override_return_data={ + "tenant": [ + { + "tenant-name": TENANT_NAME, + "tenant-id": TENANT_ID + } + ], + } + ) + mockup_catalog_item( + oc.vid.maintenance.catalog_items["GET_CATEGORY_PARAMETERS"], + override_return_data={ + "categoryParameters": { + "owningEntity": [ + { + "name": OWNING_ENTITY_NAME, + "id": OWNING_ENTITY_ID + } + ] + }, + } + ) + mockup_catalog_item( + oc.so.service_instantiation.catalog_items["CREATE_SERVICE_INSTANCE"], + override_return_data={ + "requestReferences": { + "requestId": REQUEST_ID + } + } + ) + mockup_catalog_item( + oc.so.service_instantiation.catalog_items["GET_REQUEST_STATUS"], + override_uri_params={"request_id": REQUEST_ID}, + override_return_data={ + "request": { + "requestStatus": { + "requestState": "COMPLETE" + } + } + } + ) + + si = ServiceInstance( + SERVICE_INSTANCE_NAME, + "cs0008", + SERVICE_MODEL_NAME, + "1.0", + TENANT_NAME, + CLOUD_OWNER, + CLOUD_REGION, + "GR_API", + "ONAPSERVICE", + "ONAPCUSTOMER", + "ONAPPROJECT", + OWNING_ENTITY_NAME + ) + + assert si.service_instance_name == SERVICE_INSTANCE_NAME diff --git a/onap-client/onap_client/so/tests/test_vnf_instance.py b/onap-client/onap_client/so/tests/test_vnf_instance.py new file mode 100644 index 0000000..3805da8 --- /dev/null +++ b/onap-client/onap_client/so/tests/test_vnf_instance.py @@ -0,0 +1,174 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software 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. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# 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. +# +# ============LICENSE_END============================================ +import responses +from onap_client.client.clients import Client +from onap_client.tests.utils import mockup_catalog_item +from onap_client.so.vnf_instance import VNFInstance + + +@responses.activate +def test_vnf_instance(): + oc = Client() + + SERVICE_MODEL_NAME = "service_model_name" + SERVICE_MODEL_ID = "service_model_id" + SERVICE_MODEL_INVARIANT_ID = "service_model_invariant_id" + SERVICE_INSTANCE_NAME = "service_instance_name" + SERVICE_INSTANCE_ID = "service_instance_id" + SERVICE_INSTANCE_INVARIANT_ID = "service_instance_invariant_id" + SERVICE_INSTANCE_VERSION = "service_instance_version" + SERVICE_INSTANCE_UUID = "service_instance_uuid" + + VNF_MODEL_NAME = "vnf_model_name" + VNF_INSTANCE_NAME = "vnf_instance_name" + VNF_CUSTOMIZATION_UUID = "vnf_customization_uuid" + VNF_INVARIANT_ID = "vnf_invariant_id" + VNF_ACTUAL_UUID = "vnf_actual_uuid" + VNF_VERSION = "vnf_version" + + CLOUD_OWNER = "cloud_owner" + CLOUD_REGION = "cloud_region" + TENANT_NAME = "tenant_name" + TENANT_ID = "tenant_id" + REQUEST_ID = "request_id" + + mockup_catalog_item( + oc.sdc.service.catalog_items["GET_SERVICES"], + override_return_data={ + "services": [ + { + "name": SERVICE_MODEL_NAME, + "uniqueId": SERVICE_MODEL_ID, + "lastUpdateDate": 123456, + } + ] + }, + ) + mockup_catalog_item( + oc.aai.cloud_infrastructure.catalog_items["GET_CLOUD_REGION_TENANTS"], + override_uri_params={"cloud_owner": CLOUD_OWNER, "cloud_region": CLOUD_REGION}, + override_return_data={ + "tenant": [ + { + "tenant-name": TENANT_NAME, + "tenant-id": TENANT_ID + } + ], + } + ) + mockup_catalog_item( + oc.sdc.service.catalog_items["GET_SDC_SERVICE"], + override_uri_params={"catalog_service_id": SERVICE_MODEL_ID}, + override_return_data={ + "invariantUUID": SERVICE_MODEL_INVARIANT_ID, + "uniqueId": SERVICE_MODEL_ID, + "componentInstances": [ + { + "componentName": VNF_MODEL_NAME, + "customizationUUID": VNF_CUSTOMIZATION_UUID, + "actualComponentUid": VNF_ACTUAL_UUID, + "componentVersion": VNF_VERSION + } + ] + } + ) + mockup_catalog_item( + oc.sdc.vnf.catalog_items["GET_CATALOG_RESOURCE"], + override_return_data={ + "invariantUUID": VNF_INVARIANT_ID + }, + override_uri_params={"catalog_resource_id": VNF_ACTUAL_UUID}, + ) + mockup_catalog_item( + oc.sdnc.config.catalog_items["GET_SERVICE_INSTANCES"], + override_return_data={ + "services": { + "service": [ + { + "service-data": { + "service-request-input": { + "service-instance-name": SERVICE_INSTANCE_NAME + }, + "service-information": { + "onap-model-information": { + "model-invariant-uuid": SERVICE_INSTANCE_INVARIANT_ID, + "model-uuid": SERVICE_INSTANCE_UUID, + "model-version": SERVICE_INSTANCE_VERSION, + "model-name": SERVICE_MODEL_NAME, + } + } + }, + "service-instance-id": SERVICE_INSTANCE_ID + } + ] + } + }, + ) + mockup_catalog_item( + oc.so.service_instantiation.catalog_items["CREATE_VNF_INSTANCE"], + override_return_data={ + "requestReferences": { + "requestId": REQUEST_ID + } + } + ) + mockup_catalog_item( + oc.so.service_instantiation.catalog_items["GET_REQUEST_STATUS"], + override_uri_params={"request_id": REQUEST_ID}, + override_return_data={ + "request": { + "requestStatus": { + "requestState": "COMPLETE" + } + } + } + ) + + vnfi = VNFInstance( + VNF_INSTANCE_NAME, + SERVICE_INSTANCE_NAME, + "cs0008", + VNF_MODEL_NAME, + TENANT_NAME, + CLOUD_OWNER, + CLOUD_REGION, + "GR_API", + "platform", + "lob" + ) + + assert vnfi.vnf_instance_name == VNF_INSTANCE_NAME |