aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_sp_partner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_sp_partner.py')
-rw-r--r--tests/test_sp_partner.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/test_sp_partner.py b/tests/test_sp_partner.py
new file mode 100644
index 0000000..73a4839
--- /dev/null
+++ b/tests/test_sp_partner.py
@@ -0,0 +1,84 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from unittest import mock
+
+from onapsdk.aai.business import SpPartner
+from onapsdk.exceptions import ResourceNotFound
+
+
+SP_PARTNERS = {
+ "sp-partner":[
+ {
+ "sp-partner-id":"ff6c945f-89ab-4f14-bafd-0cdd6eac791a",
+ "url":"http://127.0.0.1",
+ "resource-version":"1588244348931",
+ },
+ {
+ "sp-partner-id":"OE-generic",
+ "callsource":"test-callsource",
+ "resource-version":"1587388597761"
+ },
+ {
+ "sp-partner-id":"b3dcdbb0-edae-4384-b91e-2f114472520c",
+ "url":"http://127.0.0.1",
+ "callsource":"test-callsource",
+ "operational-status":"test-operational-status",
+ "model-customization-id":"test-model-customization-id",
+ "model-invariant-id":"test-model-invariant-id",
+ "model-version-id":"test-model-version-id",
+ "resource-version":"1588145971158"
+ }
+ ]
+}
+
+
+SP_PARTNER = {
+ "sp-partner-id":"blablabla",
+ "url":"http://127.0.0.1",
+ "callsource":"test-callsource",
+ "resource-version":"1587388597761"
+}
+
+
+@mock.patch.object(SpPartner, "send_message_json")
+def test_sp_partner_get_all(mock_send):
+ mock_send.return_value = SP_PARTNERS
+ owning_entities = list(SpPartner.get_all())
+ assert len(owning_entities) == 3
+ sp_partner = owning_entities[0]
+ assert sp_partner.sp_partner_id == "ff6c945f-89ab-4f14-bafd-0cdd6eac791a"
+ assert sp_partner.sp_partner_url == "http://127.0.0.1"
+ assert sp_partner.url == (f"{sp_partner.base_url}{sp_partner.api_version}/"
+ "business/sp-partners/sp-partner/"
+ f"{sp_partner.sp_partner_id}")
+
+
+@mock.patch.object(SpPartner, "send_message_json")
+def test_sp_partner_get_by_sp_partner_id(mock_send):
+ mock_send.return_value = SP_PARTNER
+ sp_partner = SpPartner.get_by_sp_partner_id("blablabla")
+ assert sp_partner.sp_partner_id == "blablabla"
+
+
+@mock.patch.object(SpPartner, "send_message")
+@mock.patch.object(SpPartner, "get_by_sp_partner_id")
+def test_sp_partner_create(_, mock_send):
+
+ SpPartner.create(
+ sp_partner_id="123"
+ )
+ mock_send.assert_called_once_with("PUT",
+ "Declare A&AI sp partner",
+ "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/sp-partners/sp-partner/123",
+ data='{\n "sp-partner-id": "123"\n \n \n \n \n \n \n}')