From 2af8eed99a00371db238c1021fbe110df59fd476 Mon Sep 17 00:00:00 2001 From: paweldenst Date: Mon, 19 Dec 2022 08:38:11 +0000 Subject: Create CPS anchor nodes using ODP Added required anchor-name and dataspace-name for schema Issue-ID: INT-2179 Signed-off-by: paweldenst Change-Id: I98d3b25a724af16adf4943bcd832054ed43c69f0 --- tests/test_cps_resource.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'tests/test_cps_resource.py') 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 -- cgit 1.2.3-korg