summaryrefslogtreecommitdiffstats
path: root/tests/test_service_instance_resource.py
diff options
context:
space:
mode:
authorPiotr Stanior <piotr.stanior@t-mobile.pl>2022-01-31 08:44:09 +0100
committerPiotr Stanior <piotr.stanior@t-mobile.pl>2022-01-31 14:24:40 +0100
commite9dbe96626c23204bac7426bba69b4e2aedfbd8f (patch)
tree3449c37bf36d99d996e5ee7bf328006229ee3318 /tests/test_service_instance_resource.py
parent9cc10c174cc0be43df44f27fd9a43bb8675695a9 (diff)
Allow tenant name in service instantiation
Change-Id: I26af41c8a1bf35c21f62d9b252fcd5eb9c7bbaee Signed-off-by: Piotr Stanior <piotr.stanior@t-mobile.pl> Issue-ID: INT-2048 Signed-off-by: Piotr Stanior <piotr.stanior@t-mobile.pl>
Diffstat (limited to 'tests/test_service_instance_resource.py')
-rw-r--r--tests/test_service_instance_resource.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_service_instance_resource.py b/tests/test_service_instance_resource.py
index 662aa32..04a18d6 100644
--- a/tests/test_service_instance_resource.py
+++ b/tests/test_service_instance_resource.py
@@ -172,3 +172,39 @@ def test_test_service_instance_resource_vnf_and_pnf_instantiation(mock_service_s
pnf = so_service.pnfs[0]
assert pnf.instance_name == "test_pnf_instance"
assert pnf.model_name == "test_pnf"
+
+
+@patch(
+ "onap_data_provider.resources.service_instance_resource.ServiceInstanceResource.exists",
+ new_callable=PropertyMock,
+)
+@patch("onap_data_provider.resources.service_instance_resource.Customer")
+@patch("onap_data_provider.resources.service_instance_resource.Project")
+@patch("onap_data_provider.resources.service_instance_resource.OwningEntity")
+@patch("onap_data_provider.resources.service_instance_resource.CloudRegion")
+@patch("onap_data_provider.resources.service_instance_resource.ServiceInstantiation")
+@patch("onap_data_provider.resources.service_instance_resource.Service")
+@patch("onap_data_provider.resources.service_instance_resource.AaiService")
+def test_si_resource_create_with_tenant_name(
+ mock_aai_service,
+ mock_service,
+ mock_service_instantionation,
+ mock_cr,
+ mock_oe,
+ mock_project,
+ mock_customer,
+ mock_si_resource_exists,
+):
+ data = RESOURCE_DATA_1_1
+ data.pop("tenant_id")
+ data.update({"tenant_name": "test_1"})
+ si_resource = ServiceInstanceResource(data)
+ mock_oe.get_by_owning_entity_name.side_effect = APIError
+ mock_si_resource_exists.return_value = True
+ si_resource.create()
+ mock_service.assert_not_called()
+ mock_si_resource_exists.return_value = False
+ try:
+ si_resource.create()
+ except ValueError:
+ assert True