diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-11-30 08:25:09 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2021-12-03 09:58:59 +0000 |
commit | 66e44262b8eb996c06670dcededd899dd1cbd7dc (patch) | |
tree | 3fcea0fe3317f8069281cb93c61add4b1599ab83 /tests/test_owning_entity_resource.py | |
parent | 2416a1a546c1d2922c37d513df42e9d26bbaaa42 (diff) |
Data provider release
Change-Id: Ia041a07152e8dabd87de05992d3670cbdc1ddaae
Issue-ID: INT-2010
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Diffstat (limited to 'tests/test_owning_entity_resource.py')
-rw-r--r-- | tests/test_owning_entity_resource.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_owning_entity_resource.py b/tests/test_owning_entity_resource.py new file mode 100644 index 0000000..c32351c --- /dev/null +++ b/tests/test_owning_entity_resource.py @@ -0,0 +1,51 @@ +from unittest import mock + +from onap_data_provider.resources.owning_entity_resource import ( + OwningEntityResource, + ResourceNotFound, +) + + +OWNING_ENTITY = {"name": "test-name"} + + +@mock.patch( + "onap_data_provider.resources.owning_entity_resource.OwningEntity.get_by_owning_entity_name" +) +def test_owning_entity_resource_owning_entity_property(mock_get_by_name): + + owning_entity = OwningEntityResource(OWNING_ENTITY) + mock_get_by_name.side_effect = ResourceNotFound + assert owning_entity.owning_entity is None + + mock_get_by_name.side_effect = None + assert owning_entity.owning_entity is not None + + +@mock.patch( + "onap_data_provider.resources.owning_entity_resource.OwningEntityResource.owning_entity", + new_callable=mock.PropertyMock, +) +def test_owning_entity_resource_exists(mock_owning_entity): + + owning_entity = OwningEntityResource(OWNING_ENTITY) + assert owning_entity.exists is True + mock_owning_entity.return_value = None + assert owning_entity.exists is False + + +@mock.patch( + "onap_data_provider.resources.owning_entity_resource.OwningEntityResource.exists", + new_callable=mock.PropertyMock, +) +@mock.patch( + "onap_data_provider.resources.owning_entity_resource.OwningEntity.send_message" +) +def test_owning_entity_create(mock_send_message, mock_exists): + mock_exists.return_value = True + owning_entity = OwningEntityResource(OWNING_ENTITY) + owning_entity.create() + mock_send_message.assert_not_called() + mock_exists.return_value = False + owning_entity.create() + mock_send_message.assert_called() |