aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicha? Jagie??o <michal.jagiello@t-mobile.pl>2023-06-14 13:40:56 +0000
committerGerrit Code Review <gerrit@onap.org>2023-06-14 13:40:56 +0000
commita13ff9ac968ddced994205539a494ecbdb2d6b34 (patch)
tree522b6bb2599f3f0a14305ab9fe619ae64abab24d
parent9dcfe85e44300d9bf483453c07a0d31033c28427 (diff)
parent97562cf882ad33813ce047038ada44eec9813f58 (diff)
Merge "added CPS changes in anchor"
-rw-r--r--src/onapsdk/cps/anchor.py17
-rw-r--r--tests/test_cps.py10
2 files changed, 15 insertions, 12 deletions
diff --git a/src/onapsdk/cps/anchor.py b/src/onapsdk/cps/anchor.py
index b1f9014..6e540ea 100644
--- a/src/onapsdk/cps/anchor.py
+++ b/src/onapsdk/cps/anchor.py
@@ -82,27 +82,30 @@ class Anchor(CpsElement):
auth=self.auth,
)
- def get_node(self, xpath: str, include_descendants: bool = False) -> Dict[Any, Any]:
- """Get anchor node data.
+ def get_node(self, xpath: str, descendants: int = 0) -> Dict[Any, Any]:
+ """
+ Get anchor node data.
Using XPATH get anchor's node data.
Args:
xpath (str): Anchor node xpath.
- include_descendants (bool, optional): Determies if descendants should be included in
- response. Defaults to False.
-
+ descendants (int, optional): Determines the number of descendant
+ levels that should be returned.
+ Can be -1 (all), 0 (none), or any positive number.
+ Defaults to 0.
Returns:
Dict[Any, Any]: Anchor node data.
-
"""
return self.send_message_json(
"GET",
f"Get {self.name} anchor node with {xpath} xpath",
- f"{self.url}/node?xpath={xpath}&include-descendants={include_descendants}",
+ f"{self.url}/node?xpath={xpath}"
+ f"?descendants={descendants}",
auth=self.auth
)
+
def update_node(self, xpath: str, node_data: str) -> None:
"""Update anchor node data.
diff --git a/tests/test_cps.py b/tests/test_cps.py
index 2e0d0e4..a62b53f 100644
--- a/tests/test_cps.py
+++ b/tests/test_cps.py
@@ -185,21 +185,21 @@ def test_anchor_get_node(mock_send_message_json):
mock_send_message_json.assert_called_once()
url = mock_send_message_json.call_args[0][2]
assert "xpath=test-xpath" in url
- assert "include-descendants=False" in url
+ assert "descendants=0" in url
mock_send_message_json.reset_mock()
- anchor.get_node("test-xpath-2", include_descendants=True)
+ anchor.get_node("test-xpath-2", descendants=-1)
mock_send_message_json.assert_called_once()
url = mock_send_message_json.call_args[0][2]
assert "xpath=test-xpath-2" in url
- assert "include-descendants=True" in url
+ assert "descendants=-1" in url
mock_send_message_json.reset_mock()
- anchor.get_node("test-xpath-3", include_descendants=False)
+ anchor.get_node("test-xpath-3", descendants=2)
mock_send_message_json.assert_called_once()
url = mock_send_message_json.call_args[0][2]
assert "xpath=test-xpath-3" in url
- assert "include-descendants=False" in url
+ assert "descendants=2" in url
@mock.patch("onapsdk.cps.Anchor.send_message")
def test_anchor_update_node(mock_send_message):