diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_aai_complex.py | 7 | ||||
-rw-r--r-- | tests/test_aai_geo_region.py | 4 | ||||
-rw-r--r-- | tests/test_aai_line_of_business.py | 4 | ||||
-rw-r--r-- | tests/test_aai_platform.py | 4 | ||||
-rw-r--r-- | tests/test_aai_pnf.py | 2 | ||||
-rw-r--r-- | tests/test_aai_project.py | 4 | ||||
-rw-r--r-- | tests/test_aai_site_resource.py | 35 | ||||
-rwxr-xr-x | tests/test_service.py | 6 | ||||
-rw-r--r-- | tests/test_sp_partner.py | 2 |
9 files changed, 52 insertions, 16 deletions
diff --git a/tests/test_aai_complex.py b/tests/test_aai_complex.py index 13d2cf5..8368d18 100644 --- a/tests/test_aai_complex.py +++ b/tests/test_aai_complex.py @@ -105,9 +105,10 @@ def test_cloud_region_link_to_complex(mock_add_rel): mock_add_rel.assert_called_once() relationship = mock_add_rel.call_args[0][0] assert relationship.related_to == "complex" - assert relationship.related_link == (f"aai/v13/cloud-infrastructure/complexes/" - f"complex/test_location_id") - assert len(relationship.relationship_data) == 2 + assert relationship.related_link == (f"https://aai.api.sparky.simpledemo.onap.org:30233/aai/" + f"v27/cloud-infrastructure/complexes/complex" + f"/test_location_id") + assert len(relationship.relationship_data) == 1 @mock.patch.object(Complex, "send_message_json") diff --git a/tests/test_aai_geo_region.py b/tests/test_aai_geo_region.py index b33f77a..1b11aa3 100644 --- a/tests/test_aai_geo_region.py +++ b/tests/test_aai_geo_region.py @@ -52,3 +52,7 @@ def test_geo_region_create(mock_get_geo_region_by_id, mock_send_message): GeoRegion.create("123") mock_send_message.assert_called_once() assert mock_get_geo_region_by_id.called_once_with("123") + +def test_geo_region_url(): + geo_region = GeoRegion("test-geo-region") + assert geo_region.url == "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/cloud-infrastructure/geo-regions/geo-region/test-geo-region" diff --git a/tests/test_aai_line_of_business.py b/tests/test_aai_line_of_business.py index 1bf4672..bd28c98 100644 --- a/tests/test_aai_line_of_business.py +++ b/tests/test_aai_line_of_business.py @@ -59,7 +59,7 @@ def test_line_of_business_get_by_name(mock_send): LineOfBusiness.get_by_name(name="test-name") mock_send.assert_called_once_with("GET", "Get test-name line of business", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/lines-of-business/line-of-business/test-name") + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/lines-of-business/line-of-business/test-name") @mock.patch("onapsdk.aai.business.line_of_business.LineOfBusiness.send_message") @@ -68,7 +68,7 @@ def test_line_of_business_create(_, mock_send): LineOfBusiness.create(name="test-name") mock_send.assert_called_once_with("PUT", "Declare A&AI line of business", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/lines-of-business/line-of-business/test-name", + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/lines-of-business/line-of-business/test-name", data='{\n "line-of-business-name": "test-name"\n}') diff --git a/tests/test_aai_platform.py b/tests/test_aai_platform.py index ed20e50..fbe2753 100644 --- a/tests/test_aai_platform.py +++ b/tests/test_aai_platform.py @@ -59,7 +59,7 @@ def test_platform_get_by_name(mock_send): Platform.get_by_name(name="test-name") mock_send.assert_called_once_with("GET", "Get test-name platform", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/platforms/platform/test-name") + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/platforms/platform/test-name") @mock.patch("onapsdk.aai.business.platform.Platform.send_message") @@ -68,7 +68,7 @@ def test_platform_create(_, mock_send): Platform.create(name="test-name") mock_send.assert_called_once_with("PUT", "Declare A&AI platform", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/platforms/platform/test-name", + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/platforms/platform/test-name", data='{\n "platform-name": "test-name"\n}') diff --git a/tests/test_aai_pnf.py b/tests/test_aai_pnf.py index 32e9ea7..eb2e851 100644 --- a/tests/test_aai_pnf.py +++ b/tests/test_aai_pnf.py @@ -42,7 +42,7 @@ PNF_INSTANCE = { { "related-to":"service-instance", "relationship-label":"org.onap.relationships.inventory.ComposedOf", - "related-link":"/aai/v21/business/customers/customer/test/service-subscriptions/service-subscription/test/service-instances/service-instance/4c3ab996-afdb-4956-9c4d-038b4eed3db1", + "related-link":"/aai/v27/business/customers/customer/test/service-subscriptions/service-subscription/test/service-instances/service-instance/4c3ab996-afdb-4956-9c4d-038b4eed3db1", "relationship-data":[ { "relationship-key":"customer.global-customer-id", diff --git a/tests/test_aai_project.py b/tests/test_aai_project.py index 4186772..716bac1 100644 --- a/tests/test_aai_project.py +++ b/tests/test_aai_project.py @@ -59,7 +59,7 @@ def test_project_get_by_name(mock_send): Project.get_by_name(name="test-name") mock_send.assert_called_once_with("GET", "Get test-name project", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/projects/project/test-name") + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/projects/project/test-name") @mock.patch("onapsdk.aai.business.project.Project.send_message") @@ -68,7 +68,7 @@ def test_project_create(_, mock_send): Project.create(name="test-name") mock_send.assert_called_once_with("PUT", "Declare A&AI project", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/projects/project/test-name", + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/projects/project/test-name", data='{\n "project-name": "test-name"\n}') diff --git a/tests/test_aai_site_resource.py b/tests/test_aai_site_resource.py index 68dd556..a0d4a12 100644 --- a/tests/test_aai_site_resource.py +++ b/tests/test_aai_site_resource.py @@ -11,7 +11,7 @@ # 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 +from unittest.mock import patch, MagicMock from onapsdk.aai.network.site_resource import SiteResource @@ -55,3 +55,36 @@ def test_site_resource_create(mock_get_by_site_resource_id, mock_send_message): SiteResource.create("123") mock_send_message.assert_called_once() assert mock_get_by_site_resource_id.called_once_with("123") + +@patch("onapsdk.aai.network.site_resource.SiteResource.add_relationship") +def test_site_resource_link_to_complex(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] + assert relationship.related_to == "complex" + assert relationship.related_link == "test-complex-url" + assert relationship.relationship_label == "org.onap.relationships.inventory.Uses" + assert relationship.relationship_data == [{ + "relationship-key": "complex.physical-location-id", + "relationship-value": "test-complex-physical-location-id", + }] + + +@patch("onapsdk.aai.network.site_resource.SiteResource.add_relationship") +def test_site_resource_link_to_site_resource(mock_add_relationship): + site_resource_rel = MagicMock(site_resource_id="test-site-resource-id", + url="test-site-resource-url") + site_resource = SiteResource("test-site-resource") + site_resource.link_to_site_resource(site_resource_rel) + mock_add_relationship.assert_called_once() + relationship = mock_add_relationship.call_args[0][0] + assert relationship.related_to == "site-resource" + assert relationship.related_link == "test-site-resource-url" + assert relationship.relationship_label == "org.onap.relationships.inventory.Supports" + assert relationship.relationship_data == [{ + "relationship-key": "site_resource.site-resource-id", + "relationship-value": "test-site-resource-id", + }] diff --git a/tests/test_service.py b/tests/test_service.py index 2ba61db..3a11449 100755 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -535,7 +535,6 @@ def test_get_tosca_bad_csart(requests_mock): svc.get_tosca(tempdir) assert not path.exists('/tmp/tosca_files') - def test_get_tosca_result(requests_mock): if path.exists('/tmp/tosca_files'): shutil.rmtree('/tmp/tosca_files') @@ -546,10 +545,9 @@ def test_get_tosca_result(requests_mock): content=file_content) svc = Service() svc.identifier = "12" - svc.get_tosca('directory') + svc.get_tosca('new/directory') assert not path.exists('/tmp/tosca_files') - def test_get_tosca_result_no_service_in_csar(requests_mock): if path.exists('/tmp/tosca_files'): shutil.rmtree('/tmp/tosca_files') @@ -561,7 +559,7 @@ def test_get_tosca_result_no_service_in_csar(requests_mock): svc = Service() svc.identifier = "12" with pytest.raises(ValidationError): - svc.get_tosca('directory') + svc.get_tosca('new/directory') @mock.patch.object(Service, 'send_message_json') def test_distributed_api_error(mock_send): diff --git a/tests/test_sp_partner.py b/tests/test_sp_partner.py index 73a4839..7005c02 100644 --- a/tests/test_sp_partner.py +++ b/tests/test_sp_partner.py @@ -80,5 +80,5 @@ def test_sp_partner_create(_, mock_send): ) mock_send.assert_called_once_with("PUT", "Declare A&AI sp partner", - "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v23/business/sp-partners/sp-partner/123", + "https://aai.api.sparky.simpledemo.onap.org:30233/aai/v27/business/sp-partners/sp-partner/123", data='{\n "sp-partner-id": "123"\n \n \n \n \n \n \n}') |