diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-10-26 14:35:40 +0200 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-10-26 15:05:52 +0200 |
commit | 6a3f5343f21abadd2b576a5b8418be75c8d43978 (patch) | |
tree | 1df2eecef067f71e8ef2a3b6f99cf40b79e20a0e /tests | |
parent | 9b8327e984b8ac0d213b332a6e1f975b967eb237 (diff) |
Unlink complex
Add missing method to unlink (delete relationship) with complex
Issue-ID: TEST-404
Change-Id: I393fa5a2c98dbc01a5620e8e58f8c27ebf734631
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_aai_complex.py | 8 | ||||
-rw-r--r-- | tests/test_aai_site_resource.py | 17 | ||||
-rw-r--r-- | tests/test_version.py | 2 |
3 files changed, 23 insertions, 4 deletions
diff --git a/tests/test_aai_complex.py b/tests/test_aai_complex.py index e377ef2..3719e14 100644 --- a/tests/test_aai_complex.py +++ b/tests/test_aai_complex.py @@ -103,7 +103,9 @@ def test_complex_get_all(mock_send_message_json): @mock.patch.object(CloudRegion, "add_relationship") -def test_cloud_region_link_to_complex(mock_add_rel): +@mock.patch.object(CloudRegion, "relationships", new_callable=mock.PropertyMock) +@mock.patch.object(CloudRegion, "delete_relationship") +def test_cloud_region_link_to_complex(mock_delete_relationship, mock_relationships, mock_add_rel): """Test Cloud Region linking with Complex. Test Relationship object creation @@ -124,6 +126,10 @@ def test_cloud_region_link_to_complex(mock_add_rel): f"/test_location_id") assert len(relationship.relationship_data) == 1 + mock_relationships.return_value = [relationship] + cloud_region.unlink_complex(cmplx) + mock_delete_relationship.assert_called_once_with(relationship) + @mock.patch.object(Complex, "send_message_json") def test_complex_get_by_physical_location_id(mock_send_message_json): diff --git a/tests/test_aai_site_resource.py b/tests/test_aai_site_resource.py index 2ad06bd..0150eff 100644 --- a/tests/test_aai_site_resource.py +++ b/tests/test_aai_site_resource.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch, PropertyMock from onapsdk.aai.network.site_resource import SiteResource +from onapsdk.exceptions import ResourceNotFound SITE_RESOURCE = { "site-resource-id":"123", @@ -57,10 +58,13 @@ def test_site_resource_create(mock_get_by_site_resource_id, mock_send_message): mock_get_by_site_resource_id.assert_called_once_with("123") @patch("onapsdk.aai.network.site_resource.SiteResource.add_relationship") -def test_site_resource_link_to_complex(mock_add_relationship): +@patch("onapsdk.aai.network.site_resource.SiteResource.relationships", new_callable=PropertyMock) +@patch("onapsdk.aai.network.site_resource.SiteResource.delete_relationship") +def test_site_resource_link_to_complex(mock_delete_relationship, mock_relationships, mock_add_relationship): cmplx = MagicMock(physical_location_id="test-complex-physical-location-id", url="test-complex-url") site_resource = SiteResource("test-site-resource") + site_resource.link_to_complex(cmplx) mock_add_relationship.assert_called_once() relationship = mock_add_relationship.call_args[0][0] @@ -72,6 +76,15 @@ def test_site_resource_link_to_complex(mock_add_relationship): "relationship-value": "test-complex-physical-location-id", }] + mock_relationships.return_value = [relationship] + site_resource.unlink_complex(cmplx) + mock_delete_relationship.assert_called_once_with(relationship) + + mock_delete_relationship.reset_mock() + mock_relationships.side_effect = ResourceNotFound + site_resource.unlink_complex(cmplx) + mock_delete_relationship.assert_not_called() + @patch("onapsdk.aai.network.site_resource.SiteResource.add_relationship") def test_site_resource_link_to_site_resource(mock_add_relationship): diff --git a/tests/test_version.py b/tests/test_version.py index 53652c5..6e26328 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__ == '12.5.0' + assert version.__version__ == '12.6.0' |