aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicha? Jagie??o <michal.jagiello@t-mobile.pl>2023-10-16 10:47:13 +0000
committerGerrit Code Review <gerrit@onap.org>2023-10-16 10:47:13 +0000
commitb9b646a6fdaad61cb239ef99a9b52c75ec22db99 (patch)
tree95a28068b11a6ee935115f28328883496a6a08e3
parentb013514e27ddbb34b7b44119d83f42e9f3b09033 (diff)
parent4e3e660024cfea7e145d79fabf3233d8895329f8 (diff)
Merge "Add delete-anchor method for cps"
-rw-r--r--src/onapsdk/cps/dataspace.py14
-rw-r--r--tests/test_cps.py9
2 files changed, 23 insertions, 0 deletions
diff --git a/src/onapsdk/cps/dataspace.py b/src/onapsdk/cps/dataspace.py
index e574866..df5a83c 100644
--- a/src/onapsdk/cps/dataspace.py
+++ b/src/onapsdk/cps/dataspace.py
@@ -179,6 +179,20 @@ class Dataspace(CpsElement):
dataspace=self))
@exception_handler
+ def delete_anchor(self, anchor_name: str) -> None:
+ """Delete dataspace anchor by name.
+
+ Args:
+ anchor_name (str): Anchor name.
+ """
+ self.send_message(
+ "DELETE",
+ f"Delete {anchor_name} anchor",
+ f"{self.url}/anchors/{anchor_name}",
+ auth=self.auth
+ )
+
+ @exception_handler
def get_schema_set(self, schema_set_name: str) -> SchemaSet:
"""Get schema set by name.
diff --git a/tests/test_cps.py b/tests/test_cps.py
index a62b53f..be9ed12 100644
--- a/tests/test_cps.py
+++ b/tests/test_cps.py
@@ -89,6 +89,15 @@ def test_dataspace_get_anchor(mock_send_message_json):
assert anchor.schema_set.name == "schemaSet1"
assert anchor.schema_set.dataspace == ds
+@mock.patch("onapsdk.cps.Dataspace.send_message")
+def test_dataspace_delete_anchor(mock_send_message):
+ ds = Dataspace(name="test_ds")
+ ds.delete_anchor("some-anchor")
+ mock_send_message.assert_called_once()
+ args = mock_send_message.call_args
+ assert args[0][0] == "DELETE"
+ assert args[0][2].split('/')[-1] == "some-anchor"
+
@mock.patch("onapsdk.cps.Dataspace.send_message_json")
def test_dataspace_get_schema_set(mock_send_message_json):
mock_send_message_json.return_value = DATASPACE_SCHEMA_SET