summaryrefslogtreecommitdiffstats
path: root/tests/test_cps_resource.py
diff options
context:
space:
mode:
authorpaweldenst <pawel.denst@external.t-mobile.pl>2022-12-19 08:38:11 +0000
committerpaweldenst <pawel.denst@external.t-mobile.pl>2023-01-24 09:42:05 +0000
commit2af8eed99a00371db238c1021fbe110df59fd476 (patch)
treee1d90b7b270a37da7920be8a43cce2f18da3f36c /tests/test_cps_resource.py
parent3a6c1f7f293956d6b0cff1593ca248b19e63334f (diff)
Create CPS anchor nodes using ODP
Added required anchor-name and dataspace-name for schema Issue-ID: INT-2179 Signed-off-by: paweldenst <pawel.denst@external.t-mobile.pl> Change-Id: I98d3b25a724af16adf4943bcd832054ed43c69f0
Diffstat (limited to 'tests/test_cps_resource.py')
-rw-r--r--tests/test_cps_resource.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/test_cps_resource.py b/tests/test_cps_resource.py
index 2e01ad6..365f5c2 100644
--- a/tests/test_cps_resource.py
+++ b/tests/test_cps_resource.py
@@ -14,11 +14,9 @@
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
+from onap_data_provider.resources.cps_resource import AnchorNodeResource, AnchorResource, DataspaceResource, SchemaSetResource
DATASPACE_RESOURCE_DATA = {
@@ -40,7 +38,8 @@ DATASPACE_WITH_ANCHORS_DATA = {
"anchors": [
{
"anchor-name": "test-anchor",
- "schema-set-name": "test-schema-set"
+ "schema-set-name": "test-schema-set",
+ "anchor-node-name": "test-anchor-node"
}
]
}
@@ -54,7 +53,8 @@ SCHEMA_SET_DATA = {
ANCHOR_DATA = {
"anchor-name": "test-anchor",
"dataspace-name": "test-dataspace",
- "schema-set-name": "test-schema-set"
+ "schema-set-name": "test-schema-set",
+ "anchor-node-name": "test-anchor-node"
}
@@ -162,3 +162,14 @@ def test_anchor_resource(mock_dataspace_property, mock_schema_set_property):
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()
+
+@patch("onap_data_provider.resources.cps_resource.AnchorResource.schema_set", new_callable=PropertyMock)
+@patch("onap_data_provider.resources.cps_resource.AnchorNodeResource.dataspace", new_callable=PropertyMock)
+def test_anchor_node_resource(mock_dataspace_property, mock_schema_set_property):
+ ar = AnchorNodeResource(ANCHOR_DATA)
+
+ mock_schema_set_property.side_effect = None
+ mock_schema_set_property.return_value = MagicMock()
+ ar.create()
+ mock_dataspace_property.return_value.create_node.assert_not_called()
+ mock_dataspace_property.return_value.get_anchor.assert_called_once_with("test-anchor") \ No newline at end of file