aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2022-02-09 12:30:27 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2022-02-14 11:44:09 +0000
commita8e2a839a4cb65e341c610fd2bd2e8968c754b3d (patch)
tree766c9b0c52c0e392f2ab79d87498623d1c016b77 /tests
parent0384b57fa175d45f5c3947adb488ef572669bce1 (diff)
Custom YAML tag to get already existed ONAP resources properties
Would be useful for Alloted Resources Issue-ID: INT-2075 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: Iad398a2f0c049ba73fa4569a0f2caed1311f077c
Diffstat (limited to 'tests')
-rw-r--r--tests/test_tag_handlers.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_tag_handlers.py b/tests/test_tag_handlers.py
index 719295f..c7c9ffc 100644
--- a/tests/test_tag_handlers.py
+++ b/tests/test_tag_handlers.py
@@ -1,5 +1,8 @@
from unittest.mock import patch, PropertyMock
-from onap_data_provider.tag_handlers import join, generate_random_uuid
+
+import pytest
+
+from onap_data_provider.tag_handlers import join, generate_random_uuid, resource_property
def test_generate_random_uuid():
@@ -13,3 +16,14 @@ def test_generate_random_uuid():
def test_join(mock_safe_loader):
mock_safe_loader.construct_sequence.return_value = ["-", ["cloud", "owner", "DC1"]]
assert join(mock_safe_loader, None) == "cloud-owner-DC1"
+
+
+@patch("yaml.SafeLoader", new_callable=PropertyMock)
+@patch("onap_data_provider.property_tag.sdc_service.Service")
+def test_resource_property(mock_service, mock_safe_loader):
+ mock_safe_loader.construct_scalar.return_value = "unknown"
+ with pytest.raises(ValueError, match="Resource type \"unknown\" is not supported"):
+ resource_property(mock_safe_loader, None)
+ mock_service.return_value.identifier = "123"
+ mock_safe_loader.construct_scalar.return_value = "service identifier test_name"
+ assert resource_property(mock_safe_loader, None) == "123"