aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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