diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2022-02-16 12:42:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-02-16 12:42:06 +0000 |
commit | 2f618354f55068d7663cfc5495eed906c3ae626b (patch) | |
tree | f33c600d9a90e566db1eeac90bb143773ed73ba0 /tests | |
parent | d48a5bd068f24ab406f14147ff132e0b5519f008 (diff) | |
parent | a8e2a839a4cb65e341c610fd2bd2e8968c754b3d (diff) |
Merge "Custom YAML tag to get already existed ONAP resources properties"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_tag_handlers.py | 16 |
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" |