diff options
author | 2024-07-23 08:34:09 +0200 | |
---|---|---|
committer | 2024-07-23 08:34:09 +0200 | |
commit | cd97899edcd89d6166821bf24073eb6e1738fe5b (patch) | |
tree | 43b7a0558c7ab74690f1780426eed03d83002498 | |
parent | 38e0eb7a71abc2f8e187daafaf0ac83a3ae29c07 (diff) |
Refactor AAI service instance resource
Do not require additional parameters to delete service instance (all needed information are in object)
Issue-ID: INT-404
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I9dc7953207e889bc52527a08ac24e701150c92d4
-rw-r--r-- | src/onapsdk/aai/business/service.py | 35 | ||||
-rw-r--r-- | src/onapsdk/version.py | 2 | ||||
-rw-r--r-- | tests/test_aai_service_instance.py | 19 | ||||
-rw-r--r-- | tests/test_version.py | 2 |
4 files changed, 13 insertions, 45 deletions
diff --git a/src/onapsdk/aai/business/service.py b/src/onapsdk/aai/business/service.py index 87781a5..b5ea917 100644 --- a/src/onapsdk/aai/business/service.py +++ b/src/onapsdk/aai/business/service.py @@ -551,39 +551,16 @@ class ServiceInstance(Instance): # pylint: disable=too-many-instance-attributes self._logger.debug("Delete %s service instance", self.instance_id) return ServiceDeletionRequest.send_request(self, a_la_carte) - def delete_from_aai(self, - service_subscription: "ServiceSubscription", - instance_id: str, - service_type: str = None) -> "ServiceInstance": - """Send request to AAI to delete service instance. - - Args: - service_subscription (ServiceSubscription): service subscription which is belongs to - instance_id (str): Uniquely identifies this instance of a service - service_type (str, optional): String capturing type of service.Defaults to None. - - """ - customer_instance = service_subscription.customer - customer_id = customer_instance.global_customer_id - + def delete_from_aai(self) -> "ServiceInstance": + """Send request to AAI to delete service instance.""" # calling GET api to get resource_version of service instance response = self.send_message_json("GET", - f"GET service instance {instance_id} for ", - f"{self.base_url}{self.api_version}/business/" - f"customers/customer/" - f"{customer_id}/service-subscriptions/" - f"service-subscription/" - f"{service_type}/service-instances/service-instance/" - f"{instance_id}") + f"GET service instance {self.instance_id} for ", + self.url) resource_version = str(response.get('resource-version', '')) # calling delete api to delete service instance from AAI self.send_message("DELETE", - f"Delete service instance {instance_id} for ", - f"{self.base_url}{self.api_version}/business/customers/customer/" - f"{customer_id}/service-subscriptions/" - f"service-subscription/" - f"{service_type}/service-instances/service-instance/" - f"{instance_id}?" - f"resource-version={resource_version}") + f"Delete service instance {self.instance_id} for ", + f"{self.url}?resource-version={resource_version}") diff --git a/src/onapsdk/version.py b/src/onapsdk/version.py index b268150..e8d036c 100644 --- a/src/onapsdk/version.py +++ b/src/onapsdk/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "13.0.8" +__version__ = "13.1.0" diff --git a/tests/test_aai_service_instance.py b/tests/test_aai_service_instance.py index 070c5be..9705b5f 100644 --- a/tests/test_aai_service_instance.py +++ b/tests/test_aai_service_instance.py @@ -294,18 +294,9 @@ def test_service_instance_count(mock_send_message_json): @mock.patch.object(ServiceInstance, "send_message") def test_service_deletion_request(mock_service_deletion_send_message): - mock_instance = mock.MagicMock() - mock_instance.instance_id = "test_instance_id" - mock_service_subscription = mock.MagicMock() - mock_instance.service_subscription = mock_service_subscription - - mock_service_type = mock.MagicMock() - mock_instance.service_type = "test_service_type" - - mock_self = mock.MagicMock() - - service_instance_deletion = ServiceInstance. \ - delete_from_aai(self=mock_self, instance_id=mock_instance, - service_type=mock_service_type, - service_subscription=mock_service_subscription) + si = ServiceInstance(service_subscription=mock.MagicMock(), + instance_id="test_service_instance_id") + si.delete_from_aai() + mock_service_deletion_send_message.assert_called() + assert mock_service_deletion_send_message.call_count == 2 diff --git a/tests/test_version.py b/tests/test_version.py index 36e0c96..af14554 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__ == '13.0.8' + assert version.__version__ == '13.1.0' |