aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPiotr Stanior <piotr.stanior@t-mobile.pl>2022-02-02 15:14:47 +0100
committerPiotr Stanior <piotr.stanior@t-mobile.pl>2022-02-03 14:44:31 +0100
commit7f6332466912bbc0886756d40e34128861a39259 (patch)
treeb15fdb446e440d09c74c1300295ba41de1d06920 /tests
parente9dbe96626c23204bac7426bba69b4e2aedfbd8f (diff)
Add vfc resource support for xnfs
Change-Id: I8caa5174e35167f1bd26fe4a950af2cd7fe63ead Signed-off-by: Piotr Stanior <piotr.stanior@t-mobile.pl> Issue-ID: INT-2058 Signed-off-by: Piotr Stanior <piotr.stanior@t-mobile.pl>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pnf_resource.py36
-rw-r--r--tests/test_vnf_resource.py36
2 files changed, 70 insertions, 2 deletions
diff --git a/tests/test_pnf_resource.py b/tests/test_pnf_resource.py
index c58717a..62dc3ae 100644
--- a/tests/test_pnf_resource.py
+++ b/tests/test_pnf_resource.py
@@ -1,4 +1,4 @@
-from unittest.mock import patch, PropertyMock
+from unittest.mock import MagicMock, patch, PropertyMock
from onap_data_provider.resources.pnf_resource import PnfResource
@@ -26,3 +26,37 @@ def test_pnf_resource_pnf(mock_pnf_created):
assert pnf_resource.pnf is None
mock_pnf_created.return_value = True
assert pnf_resource.pnf is not None
+
+
+@patch(
+ "onap_data_provider.resources.pnf_resource.Pnf.create",
+)
+@patch(
+ "onap_data_provider.resources.pnf_resource.Pnf.add_resource",
+)
+@patch(
+ "onap_data_provider.resources.pnf_resource.Pnf.onboard",
+)
+@patch(
+ "onap_data_provider.resources.pnf_resource.PnfResource.pnf",
+ new_callable=PropertyMock,
+)
+@patch(
+ "onap_data_provider.resources.xnf_resource.Vfc",
+)
+def test_pnf_resource_onboards_with_vfc(
+ mock_vfc, mock_pnf, mock_onboard, mock_add_resource, mock_pnf_create
+):
+ mock_vfc = MagicMock()
+ mock_pnf.return_value = None
+ data_no_composition = {"name": "test_pnf"}
+ pnf_resource = PnfResource(data_no_composition)
+ pnf_resource.create()
+ mock_add_resource.assert_not_called()
+ data_with_composition = {
+ "name": "test_pnf",
+ "resources": [{"name": "test", "xnf_type": "VFC"}],
+ }
+ pnf_resource = PnfResource(data_with_composition)
+ pnf_resource.create()
+ mock_add_resource.assert_called_once()
diff --git a/tests/test_vnf_resource.py b/tests/test_vnf_resource.py
index 6398aec..e35cded 100644
--- a/tests/test_vnf_resource.py
+++ b/tests/test_vnf_resource.py
@@ -1,4 +1,4 @@
-from unittest.mock import patch, PropertyMock
+from unittest.mock import MagicMock, patch, PropertyMock
from onap_data_provider.resources.vnf_resource import VnfResource
@@ -26,3 +26,37 @@ def test_vnf_resource_vnf(mock_vnf_created):
assert vnf_resource.vnf is None
mock_vnf_created.return_value = True
assert vnf_resource.vnf is not None
+
+
+@patch(
+ "onap_data_provider.resources.vnf_resource.Vf.create",
+)
+@patch(
+ "onap_data_provider.resources.vnf_resource.Vf.add_resource",
+)
+@patch(
+ "onap_data_provider.resources.vnf_resource.Vf.onboard",
+)
+@patch(
+ "onap_data_provider.resources.vnf_resource.VnfResource.vnf",
+ new_callable=PropertyMock,
+)
+@patch(
+ "onap_data_provider.resources.xnf_resource.Vfc",
+)
+def test_vnf_resource_onboards_with_vfc(
+ mock_vfc, mock_vnf, mock_onboard, mock_add_resource, mock_vnf_create
+):
+ mock_vfc = MagicMock()
+ mock_vnf.return_value = None
+ data_no_composition = {"name": "test_vnf"}
+ vnf_resource = VnfResource(data_no_composition)
+ vnf_resource.create()
+ mock_add_resource.assert_not_called()
+ data_with_composition = {
+ "name": "test_vnf",
+ "resources": [{"name": "test", "xnf_type": "VFC"}],
+ }
+ vnf_resource = VnfResource(data_with_composition)
+ vnf_resource.create()
+ mock_add_resource.assert_called_once()