aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_service.py
diff options
context:
space:
mode:
authorankitg@aarnanetworks.com <ankitg@aarnanetworks.com>2023-01-16 08:22:04 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2023-01-16 12:55:40 +0000
commit956bef308145fa3fb2263bd66a94c562a6f466b8 (patch)
tree89885547436aab9b39fcb498f6f6aea4f8dc6aa2 /tests/test_service.py
parenta805ee54d2727f3d269d960e3801b4c53551565e (diff)
Archive and delete SDC Resources
Issue-ID: INT-2193 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: Ic63628440059bacac03689d61859c6a72f7780df
Diffstat (limited to 'tests/test_service.py')
-rwxr-xr-xtests/test_service.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/test_service.py b/tests/test_service.py
index 7606ed2..2ba61db 100755
--- a/tests/test_service.py
+++ b/tests/test_service.py
@@ -15,10 +15,10 @@
from os import path
from pathlib import Path
+from tempfile import TemporaryDirectory
from unittest import mock
from unittest.mock import MagicMock, PropertyMock
import shutil
-import oyaml as yaml
import pytest
import onapsdk.constants as const
from onapsdk.exceptions import ParameterError, RequestError, ResourceNotFound, StatusError, ValidationError
@@ -531,7 +531,8 @@ def test_get_tosca_bad_csart(requests_mock):
requests_mock.get(
'https://sdc.api.be.simpledemo.onap.org:30204/sdc/v1/catalog/services/12/toscaModel',
content=file_content)
- svc.get_tosca('directory')
+ with TemporaryDirectory() as tempdir:
+ svc.get_tosca(tempdir)
assert not path.exists('/tmp/tosca_files')
@@ -1490,10 +1491,27 @@ def test_service_components(mock_send_message_json):
assert not service.has_vnfs
assert not service.has_pnfs
assert not service.has_vls
-
mock_send_message_json.side_effect = [COMPONENTS_WITH_ALL_ORIGIN_TYPES, COMPONENT,
COMPONENTS_WITH_ALL_ORIGIN_TYPES, COMPONENT, COMPONENT,
COMPONENTS_WITH_ALL_ORIGIN_TYPES, COMPONENT, COMPONENT, COMPONENT]
assert service.has_vnfs
assert service.has_pnfs
assert service.has_vls
+
+@mock.patch.object(Service, "send_message")
+def test_service_archive(mock_send):
+ service = Service(name="test")
+ service.archive()
+ mock_send.assert_called()
+ method, description, url = mock_send.call_args[0]
+ assert method == "POST"
+ assert description == "Archive test component"
+ assert "archive" in url
+
+@mock.patch.object(Service, "send_message")
+def test_service_delete(mock_send):
+ service = Service(name="test")
+ service.delete()
+ mock_send.assert_called()
+ method = mock_send.call_args[0][0]
+ assert method == "DELETE"