diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2022-10-17 12:46:49 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2022-10-17 14:05:09 +0000 |
commit | f2adf542e878c96895210f97ebf1ebb763b2f465 (patch) | |
tree | 91fc0faeb3436e723d07aed1f38ce59a6e7cc7c5 /tests/test_sp_partner.py | |
parent | 49071a0d0425ef67fa552dbf14c81e5a11cc49e7 (diff) |
Release ONAP SDKv10.2
Issue-ID: INT-2150
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I650047c599a5aae6de7c6b42d38e34aea88578e2
Diffstat (limited to 'tests/test_sp_partner.py')
-rw-r--r-- | tests/test_sp_partner.py | 84 |
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}') |