diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-12-19 09:34:03 +0100 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-12-19 09:44:36 +0100 |
commit | 4474aafa07d378be7c896821e2af86c3deb1e2d3 (patch) | |
tree | 40ae6afe627cd2447a0ece5c6894c2b15fe8eb7e /tests | |
parent | ec7d9491a6f4cfa90e1140cc51975c98b6a555e8 (diff) |
Refactor CPS module url creation
Switch from string formatting into urllib urljoin.
Fix issue with invalid CPS requests urls
Issue-ID: INT-2277
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I37583aa3517be6cc27ed547ca6b11b19d6ccaca7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cps.py | 48 | ||||
-rw-r--r-- | tests/test_version.py | 2 |
2 files changed, 25 insertions, 25 deletions
diff --git a/tests/test_cps.py b/tests/test_cps.py index be9ed12..9be0940 100644 --- a/tests/test_cps.py +++ b/tests/test_cps.py @@ -177,7 +177,7 @@ def test_anchor_delete(mock_send_message): anchor.delete() mock_send_message.assert_called_once() url = mock_send_message.call_args[0][2] - assert anchor.url in url + assert anchor.url.rstrip("/") in url @mock.patch("onapsdk.cps.Anchor.send_message") def test_anchor_create_node(mock_send_message): @@ -192,71 +192,71 @@ def test_anchor_get_node(mock_send_message_json): anchor = Anchor(name="test_anchor", schema_set=mock.MagicMock()) anchor.get_node("test-xpath") mock_send_message_json.assert_called_once() - url = mock_send_message_json.call_args[0][2] - assert "xpath=test-xpath" in url - assert "descendants=0" in url + params = mock_send_message_json.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath" + assert "descendants" in params and params["descendants"] == 0 mock_send_message_json.reset_mock() 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 "descendants=-1" in url + params = mock_send_message_json.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath-2" + assert "descendants" in params and params["descendants"] == -1 mock_send_message_json.reset_mock() 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 "descendants=2" in url + params = mock_send_message_json.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath-3" + assert "descendants" in params and params["descendants"] == 2 @mock.patch("onapsdk.cps.Anchor.send_message") def test_anchor_update_node(mock_send_message): anchor = Anchor(name="test_anchor", schema_set=mock.MagicMock()) anchor.update_node("test-xpath", '{"test": "data"}') mock_send_message.assert_called_once() - url = mock_send_message.call_args[0][2] - assert "xpath=test-xpath" in url + params = mock_send_message.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath" @mock.patch("onapsdk.cps.Anchor.send_message") def test_anchor_replace_node(mock_send_message): anchor = Anchor(name="test_anchor", schema_set=mock.MagicMock()) anchor.replace_node("test-xpath", '{"test": "data"}') mock_send_message.assert_called_once() - url = mock_send_message.call_args[0][2] - assert "xpath=test-xpath" in url + params = mock_send_message.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath" @mock.patch("onapsdk.cps.Anchor.send_message") def test_anchor_add_list_node(mock_send_message): anchor = Anchor(name="test_anchor", schema_set=mock.MagicMock()) anchor.add_list_node("test-xpath", '{"test": "data"}') mock_send_message.assert_called_once() - url = mock_send_message.call_args[0][2] - assert "xpath=test-xpath" in url + params = mock_send_message.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath" @mock.patch("onapsdk.cps.Anchor.send_message_json") def test_anchor_query_node(mock_send_message_json): anchor = Anchor(name="test_anchor", schema_set=mock.MagicMock()) anchor.query_node("/test-query") mock_send_message_json.assert_called_once() - url = mock_send_message_json.call_args[0][2] - assert "cps-path=/test-query" in url - assert "include-descendants=False" in url + params = mock_send_message_json.call_args.kwargs["params"] + assert "cps-path" in params and params["cps-path"] == "/test-query" + assert "include-descendants" in params and params["include-descendants"] is False mock_send_message_json.reset_mock() anchor.query_node("/test-query1", include_descendants=True) mock_send_message_json.assert_called_once() - url = mock_send_message_json.call_args[0][2] - assert "cps-path=/test-query1" in url - assert "include-descendants=True" in url + params = mock_send_message_json.call_args.kwargs["params"] + assert "cps-path" in params and params["cps-path"] == "/test-query1" + assert "include-descendants" in params and params["include-descendants"] is True @mock.patch("onapsdk.cps.Anchor.send_message") def test_anchor_delete_nodes(mock_send_message): anchor = Anchor(name="test_anchor", schema_set=mock.MagicMock()) anchor.delete_nodes("test-xpath") mock_send_message.assert_called_once() - url = mock_send_message.call_args[0][2] - assert "xpath=test-xpath" in url + params = mock_send_message.call_args.kwargs["params"] + assert "xpath" in params and params["xpath"] == "test-xpath" @mock.patch("onapsdk.cps.Dataspace.send_message") def test_dataspace_create_anchor_except(mock_send_message_json): diff --git a/tests/test_version.py b/tests/test_version.py index 600e562..bf3b69b 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -17,4 +17,4 @@ import onapsdk.version as version def test_version(): """Check version is the right one.""" - assert version.__version__ == '12.7.2' + assert version.__version__ == '12.7.3' |