diff --git a/fossology/__init__.py b/fossology/__init__.py index ce9f540..68c0aa0 100644 --- a/fossology/__init__.py +++ b/fossology/__init__.py @@ -107,7 +107,7 @@ def __init__(self, url, token, name=None): self.users = list() self.folders = list() - self.api = f"{self.host}/api/v1" + self.api = f"{self.host}/api/v2" self.session = requests.Session() self.session.headers.update({"Authorization": f"Bearer {self.token}"}) self.info = self.get_info() diff --git a/tests/test_folders.py b/tests/test_folders.py index ab43408..34681e4 100644 --- a/tests/test_folders.py +++ b/tests/test_folders.py @@ -14,7 +14,7 @@ @responses.activate def test_list_folders_error(foss_server: str, foss: Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/folders", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/folders", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.list_folders() assert f"Unable to get a list of folders for {foss.user.name}" in str(excinfo.value) @@ -69,7 +69,7 @@ def test_create_folder_no_parent(foss: Fossology): def test_create_folder_returns_200_but_folder_does_not_exists( foss_server: str, foss: Fossology ): - responses.add(responses.POST, f"{foss_server}/api/v1/folders", status=200) + responses.add(responses.POST, f"{foss_server}/api/v2/folders", status=200) with pytest.raises(FossologyApiError) as excinfo: foss.create_folder(foss.rootFolder, "NoFolder") assert ( @@ -81,7 +81,7 @@ def test_create_folder_returns_200_but_folder_does_not_exists( @responses.activate def test_create_folder_error(foss_server: str, foss: Fossology): parent = Folder(secrets.randbelow(1000), "NonFolder", "", foss.rootFolder) - responses.add(responses.POST, f"{foss_server}/api/v1/folders", status=404) + responses.add(responses.POST, f"{foss_server}/api/v2/folders", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.create_folder(parent, "TestFolderNoParent") assert "Unable to create folder TestFolderNoParent" in str(excinfo.value) @@ -106,7 +106,7 @@ def test_update_folder(foss: Fossology): def test_update_folder_error(foss_server: str, foss: Fossology): folder = Folder(secrets.randbelow(1000), "Folder", "", foss.rootFolder) responses.add( - responses.PATCH, f"{foss_server}/api/v1/folders/{folder.id}", status=404 + responses.PATCH, f"{foss_server}/api/v2/folders/{folder.id}", status=404 ) with pytest.raises(FossologyApiError) as excinfo: foss.update_folder(folder) @@ -152,7 +152,7 @@ def test_copy_folder(foss: Fossology): def test_put_folder_error(foss_server: str, foss: Fossology): folder = Folder(secrets.randbelow(1000), "Folder", "", foss.rootFolder) responses.add( - responses.PUT, f"{foss_server}/api/v1/folders/{folder.id}", status=404 + responses.PUT, f"{foss_server}/api/v2/folders/{folder.id}", status=404 ) with pytest.raises(FossologyApiError) as excinfo: foss.move_folder(folder, foss.rootFolder) @@ -178,7 +178,7 @@ def test_delete_folder(foss: Fossology): def test_delete_folder_error(foss_server: str, foss: Fossology): folder = Folder(secrets.randbelow(1000), "Folder", "", foss.rootFolder) responses.add( - responses.DELETE, f"{foss_server}/api/v1/folders/{folder.id}", status=404 + responses.DELETE, f"{foss_server}/api/v2/folders/{folder.id}", status=404 ) with pytest.raises(FossologyApiError) as excinfo: foss.delete_folder(folder) diff --git a/tests/test_groups.py b/tests/test_groups.py index f16ba9b..dfe48ec 100644 --- a/tests/test_groups.py +++ b/tests/test_groups.py @@ -33,7 +33,7 @@ def verify_user_group_membership( # Test functions @responses.activate def test_list_groups_error(foss_server: str, foss: fossology.Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/groups", status=500) + responses.add(responses.GET, f"{foss_server}/api/v2/groups", status=500) with pytest.raises(FossologyApiError) as excinfo: foss.list_groups() assert f"Unable to get a list of groups for {foss.user.name}" in str(excinfo.value) @@ -41,7 +41,7 @@ def test_list_groups_error(foss_server: str, foss: fossology.Fossology): @responses.activate def test_list_group_members_error(foss_server: str, foss: fossology.Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/groups/42/members", status=500) + responses.add(responses.GET, f"{foss_server}/api/v2/groups/42/members", status=500) with pytest.raises(FossologyApiError) as excinfo: foss.list_group_members(42) assert "Unable to get a list of members for group 42" in str(excinfo.value) @@ -52,7 +52,7 @@ def test_delete_group_member_validation_error( foss_server: str, foss: fossology.Fossology ): responses.add( - responses.DELETE, f"{foss_server}/api/v1/groups/42/user/42", status=400 + responses.DELETE, f"{foss_server}/api/v2/groups/42/user/42", status=400 ) with pytest.raises(FossologyApiError) as excinfo: foss.delete_group_member(42, 42) @@ -64,7 +64,7 @@ def test_delete_group_member_validation_error( @responses.activate def test_delete_group_member_error(foss_server: str, foss: fossology.Fossology): responses.add( - responses.DELETE, f"{foss_server}/api/v1/groups/42/user/42", status=500 + responses.DELETE, f"{foss_server}/api/v2/groups/42/user/42", status=500 ) with pytest.raises(FossologyApiError) as excinfo: foss.delete_group_member(42, 42) @@ -77,7 +77,7 @@ def test_delete_group_member_error(foss_server: str, foss: fossology.Fossology): def test_delete_group_error(foss_server: str, foss: fossology.Fossology): group_id = secrets.randbelow(10) responses.add( - responses.DELETE, f"{foss_server}/api/v1/groups/{group_id}", status=500 + responses.DELETE, f"{foss_server}/api/v2/groups/{group_id}", status=500 ) with pytest.raises(FossologyApiError) as excinfo: foss.delete_group(group_id) diff --git a/tests/test_init.py b/tests/test_init.py index 3c26cd0..cf22e15 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -18,7 +18,7 @@ def test_get_info(foss: Fossology): def test_info_does_not_return_200(foss_server: str, foss: Fossology): responses.add( responses.GET, - f"{foss_server}/api/v1/info", + f"{foss_server}/api/v2/info", status=400, ) with pytest.raises(FossologyApiError) as excinfo: @@ -36,7 +36,7 @@ def test_get_health(foss: Fossology): def test_health_does_not_return_200(foss_server: str, foss: Fossology): responses.add( responses.GET, - f"{foss_server}/api/v1/health", + f"{foss_server}/api/v2/health", status=503, ) with pytest.raises(FossologyApiError) as excinfo: diff --git a/tests/test_items.py b/tests/test_items.py index dd05da5..dcd4149 100644 --- a/tests/test_items.py +++ b/tests/test_items.py @@ -30,7 +30,7 @@ def test_item_info_500_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload_with_jobs.id}/item/1/info", + f"{foss_server}/api/v2/uploads/{upload_with_jobs.id}/item/1/info", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -63,7 +63,7 @@ def test_item_copyrights_500_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload_with_jobs.id}/item/1/totalcopyrights", + f"{foss_server}/api/v2/uploads/{upload_with_jobs.id}/item/1/totalcopyrights", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -94,7 +94,7 @@ def test_upload_get_clearing_history_500_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload_with_jobs.id}/item/1/clearing-history", + f"{foss_server}/api/v2/uploads/{upload_with_jobs.id}/item/1/clearing-history", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -125,7 +125,7 @@ def test_upload_get_bulk_history_500_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload_with_jobs.id}/item/1/clearing-history", + f"{foss_server}/api/v2/uploads/{upload_with_jobs.id}/item/1/clearing-history", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -166,7 +166,7 @@ def test_schedule_bulk_scan_500_error( ): responses.add( responses.POST, - f"{foss_server}/api/v1/uploads/{upload_with_jobs.id}/item/1/bulk-scan", + f"{foss_server}/api/v2/uploads/{upload_with_jobs.id}/item/1/bulk-scan", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -213,7 +213,7 @@ def test_upload_get_prev_next_500_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload_with_jobs.id}/item/1/prev-next", + f"{foss_server}/api/v2/uploads/{upload_with_jobs.id}/item/1/prev-next", status=500, ) with pytest.raises(FossologyApiError) as excinfo: diff --git a/tests/test_jobs.py b/tests/test_jobs.py index df592da..b3b21dc 100644 --- a/tests/test_jobs.py +++ b/tests/test_jobs.py @@ -61,7 +61,7 @@ def test_detail_job_wait_completed( @responses.activate def test_schedule_job_error(foss_server: str, foss: Fossology, upload: Upload): - responses.add(responses.POST, f"{foss_server}/api/v1/jobs", status=404) + responses.add(responses.POST, f"{foss_server}/api/v2/jobs", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.schedule_jobs(foss.rootFolder, upload, {}) assert f"Scheduling jobs for upload {upload.uploadname} failed" in str( @@ -71,7 +71,7 @@ def test_schedule_job_error(foss_server: str, foss: Fossology, upload: Upload): @responses.activate def test_list_jobs_error(foss_server: str, foss: Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/jobs", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/jobs", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.list_jobs() assert "Unable to retrieve the list of jobs from page 1" in str(excinfo.value) @@ -79,7 +79,7 @@ def test_list_jobs_error(foss_server: str, foss: Fossology): @responses.activate def test_list_all_jobs_access_denied(foss_server: str, foss: Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/jobs/all", status=403) + responses.add(responses.GET, f"{foss_server}/api/v2/jobs/all", status=403) with pytest.raises(FossologyApiError) as excinfo: foss.list_jobs(all=True) assert "Access denied to /jobs/all endpoint" in str(excinfo.value) @@ -88,8 +88,8 @@ def test_list_all_jobs_access_denied(foss_server: str, foss: Fossology): @responses.activate def test_detail_job_error(foss_server: str, foss: Fossology): job_id = secrets.randbelow(1000) - responses.add(responses.GET, f"{foss_server}/api/v1/jobs/{job_id}", status=404) - responses.add(responses.GET, f"{foss_server}/api/v1/jobs/{job_id}", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/jobs/{job_id}", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/jobs/{job_id}", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.detail_job(job_id, wait=True) assert f"Error while getting details for job {job_id}" in str(excinfo.value) diff --git a/tests/test_license.py b/tests/test_license.py index c74b96a..5d54f85 100644 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -34,7 +34,7 @@ def test_another_license(): @responses.activate def test_detail_license_error(foss_server: str, foss: fossology.Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/license/Blah", status=500) + responses.add(responses.GET, f"{foss_server}/api/v2/license/Blah", status=500) with pytest.raises(FossologyApiError) as excinfo: foss.detail_license("Blah") assert "Error while getting license Blah" in str(excinfo.value) @@ -48,7 +48,7 @@ def test_detail_license_not_found(foss: fossology.Fossology): @responses.activate def test_list_licenses_error(foss_server: str, foss: fossology.Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/license", status=500) + responses.add(responses.GET, f"{foss_server}/api/v2/license", status=500) with pytest.raises(FossologyApiError) as excinfo: foss.list_licenses() assert "Unable to retrieve the list of licenses from page 1" in str(excinfo.value) @@ -76,7 +76,7 @@ def test_get_all_candidate_licenses(foss: fossology.Fossology): def test_add_license_error( foss_server: str, foss: fossology.Fossology, test_license: License ): - responses.add(responses.POST, f"{foss_server}/api/v1/license", status=500) + responses.add(responses.POST, f"{foss_server}/api/v2/license", status=500) with pytest.raises(FossologyApiError) as excinfo: foss.add_license(test_license) assert f"Error while adding new license {test_license.shortName}" in str( @@ -93,7 +93,7 @@ def test_add_license_already_exists( ): mocked_logger = MagicMock() monkeypatch.setattr("fossology.license.logger", mocked_logger) - responses.add(responses.POST, f"{foss_server}/api/v1/license", status=409) + responses.add(responses.POST, f"{foss_server}/api/v2/license", status=409) foss.add_license(test_license) mocked_logger.info.assert_called_once() @@ -125,7 +125,7 @@ def test_patch_license_error( foss_server: str, foss: fossology.Fossology, test_license: License ): responses.add( - responses.PATCH, f"{foss_server}/api/v1/license/License-1.0", status=500 + responses.PATCH, f"{foss_server}/api/v2/license/License-1.0", status=500 ) with pytest.raises(FossologyApiError) as excinfo: foss.update_license(test_license.shortName) diff --git a/tests/test_report.py b/tests/test_report.py index b3a25ad..2ec7022 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -51,11 +51,11 @@ def test_generate_report(foss: Fossology, upload: Upload): def test_report_error(foss_server: str, foss: Fossology, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/report", + f"{foss_server}/api/v2/report", status=503, headers={"Retry-After": "1"}, ) - responses.add(responses.GET, f"{foss_server}/api/v1/report", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/report", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.generate_report(upload) assert f"Report generation for upload {upload.uploadname} failed" in str( @@ -68,7 +68,7 @@ def test_download_report_error(foss_server: str, foss: Fossology): report_id = secrets.randbelow(1000) responses.add( responses.GET, - f"{foss_server}/api/v1/report/{report_id}", + f"{foss_server}/api/v2/report/{report_id}", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -81,7 +81,7 @@ def test_download_report_filename_without_quotes(foss_server: str, foss: Fossolo report_id = "1" responses.add( responses.GET, - f"{foss_server}/api/v1/report/{report_id}", + f"{foss_server}/api/v2/report/{report_id}", status=200, headers={"Content-Disposition": "attachment; filename=Report_FileName.docx"}, ) @@ -94,7 +94,7 @@ def test_download_report_filename_with_quotes(foss_server: str, foss: Fossology) report_id = "1" responses.add( responses.GET, - f"{foss_server}/api/v1/report/{report_id}", + f"{foss_server}/api/v2/report/{report_id}", status=200, headers={"Content-Disposition": 'attachment; filename="Report_FileName.docx"'}, ) @@ -107,7 +107,7 @@ def test_download_report_filename_with_single_quotes(foss_server: str, foss: Fos report_id = "1" responses.add( responses.GET, - f"{foss_server}/api/v1/report/{report_id}", + f"{foss_server}/api/v2/report/{report_id}", status=200, headers={"Content-Disposition": "attachment; filename='Report_FileName.docx'"}, ) diff --git a/tests/test_search.py b/tests/test_search.py index 2e5a389..182061f 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -74,7 +74,7 @@ def test_search_upload_does_not_exist(foss: Fossology): @responses.activate def test_search_error(foss_server: str, foss: Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/search", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/search", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.search() assert "Unable to get a result with the given search criteria" in str(excinfo.value) @@ -108,7 +108,7 @@ def test_filesearch_nogroup(foss: Fossology): @responses.activate def test_filesearch_error(foss_server: str, foss: Fossology): - responses.add(responses.POST, f"{foss_server}/api/v1/filesearch", status=404) + responses.add(responses.POST, f"{foss_server}/api/v2/filesearch", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.filesearch() assert "Unable to get a result with the given filesearch criteria" in str( diff --git a/tests/test_upload_licenses_copyrights.py b/tests/test_upload_licenses_copyrights.py index 95d0a18..6e019ec 100644 --- a/tests/test_upload_licenses_copyrights.py +++ b/tests/test_upload_licenses_copyrights.py @@ -51,7 +51,7 @@ def test_upload_licenses_with_unknown_group_raises_authorization_error( def test_upload_licenses_412_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/licenses", + f"{foss_server}/api/v2/uploads/{upload.id}/licenses", status=412, ) with pytest.raises(FossologyApiError) as excinfo: @@ -66,7 +66,7 @@ def test_upload_licenses_412_error(foss: Fossology, foss_server: str, upload: Up def test_upload_licenses_503_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/licenses", + f"{foss_server}/api/v2/uploads/{upload.id}/licenses", status=503, ) with pytest.raises(RetryError): @@ -77,7 +77,7 @@ def test_upload_licenses_503_error(foss: Fossology, foss_server: str, upload: Up def test_upload_licenses_500_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/licenses", + f"{foss_server}/api/v2/uploads/{upload.id}/licenses", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -97,7 +97,7 @@ def test_upload_copyrights(foss: Fossology, upload_with_jobs: Upload): def test_upload_copyrights_403_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/copyrights", + f"{foss_server}/api/v2/uploads/{upload.id}/copyrights", status=403, ) with pytest.raises(AuthorizationError) as excinfo: @@ -112,7 +112,7 @@ def test_upload_copyrights_403_error(foss: Fossology, foss_server: str, upload: def test_upload_copyrights_412_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/copyrights", + f"{foss_server}/api/v2/uploads/{upload.id}/copyrights", status=412, ) with pytest.raises(FossologyApiError) as excinfo: @@ -127,7 +127,7 @@ def test_upload_copyrights_412_error(foss: Fossology, foss_server: str, upload: def test_upload_copyrights_503_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/copyrights", + f"{foss_server}/api/v2/uploads/{upload.id}/copyrights", status=503, ) with pytest.raises(RetryError): @@ -138,7 +138,7 @@ def test_upload_copyrights_503_error(foss: Fossology, foss_server: str, upload: def test_upload_copyrights_500_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/copyrights", + f"{foss_server}/api/v2/uploads/{upload.id}/copyrights", status=500, ) with pytest.raises(FossologyApiError) as excinfo: diff --git a/tests/test_upload_permissions.py b/tests/test_upload_permissions.py index f42d322..1b2f5f5 100644 --- a/tests/test_upload_permissions.py +++ b/tests/test_upload_permissions.py @@ -58,7 +58,7 @@ def test_get_upload_permissions_if_api_returns_403_raises_authorization_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/perm-groups", + f"{foss_server}/api/v2/uploads/{upload.id}/perm-groups", status=403, ) with pytest.raises(AuthorizationError) as excinfo: @@ -74,7 +74,7 @@ def test_get_upload_permissions_if_api_returns_500_raises_fossology_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/perm-groups", + f"{foss_server}/api/v2/uploads/{upload.id}/perm-groups", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -108,7 +108,7 @@ def test_change_upload_permissions_if_api_returns_400_raises_fossology_error( ): responses.add( responses.PUT, - f"{foss_server}/api/v1/uploads/{upload.id}/permissions", + f"{foss_server}/api/v2/uploads/{upload.id}/permissions", status=400, ) with pytest.raises(FossologyApiError) as excinfo: @@ -124,7 +124,7 @@ def test_change_upload_permissions_if_api_returns_403_raises_authorization_error ): responses.add( responses.PUT, - f"{foss_server}/api/v1/uploads/{upload.id}/permissions", + f"{foss_server}/api/v2/uploads/{upload.id}/permissions", status=403, ) with pytest.raises(AuthorizationError) as excinfo: @@ -140,7 +140,7 @@ def test_change_upload_permissions_if_api_returns_500_raises_fossology_error( ): responses.add( responses.PUT, - f"{foss_server}/api/v1/uploads/{upload.id}/permissions", + f"{foss_server}/api/v2/uploads/{upload.id}/permissions", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -157,7 +157,7 @@ def test_change_upload_permissions_if_api_returns_503_raises_fossology_error( ): responses.add( responses.PUT, - f"{foss_server}/api/v1/uploads/{upload.id}/permissions", + f"{foss_server}/api/v2/uploads/{upload.id}/permissions", status=503, ) with pytest.raises(FossologyApiError) as excinfo: diff --git a/tests/test_uploads.py b/tests/test_uploads.py index 0414458..b63ad33 100644 --- a/tests/test_uploads.py +++ b/tests/test_uploads.py @@ -47,7 +47,7 @@ def test_get_upload_error(foss: Fossology, foss_server: str): upload_id = 100 responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload_id}", + f"{foss_server}/api/v2/uploads/{upload_id}", status=500, ) with pytest.raises(FossologyApiError) as excinfo: @@ -120,7 +120,7 @@ def test_empty_upload(foss: Fossology): def test_upload_error(foss: Fossology, foss_server: str, test_file_path: str): responses.add( responses.POST, - f"{foss_server}/api/v1/uploads", + f"{foss_server}/api/v2/uploads", status=500, ) description = "Test upload API error" @@ -159,7 +159,7 @@ def test_move_upload_to_non_existing_folder(foss: Fossology, upload: Upload): def test_move_upload_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.PUT, - f"{foss_server}/api/v1/uploads/{upload.id}", + f"{foss_server}/api/v2/uploads/{upload.id}", status=500, ) with pytest.raises(FossologyApiError): @@ -183,7 +183,7 @@ def test_update_upload_with_unknown_group_raises_error(foss: Fossology, upload: def test_update_upload_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.PATCH, - f"{foss_server}/api/v1/uploads/{upload.id}", + f"{foss_server}/api/v2/uploads/{upload.id}", status=500, ) with pytest.raises(FossologyApiError): @@ -204,7 +204,7 @@ def test_upload_summary(foss: Fossology, upload: Upload): def test_upload_summary_500_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/summary", + f"{foss_server}/api/v2/uploads/{upload.id}/summary", status=500, ) with pytest.raises(FossologyApiError): @@ -275,7 +275,7 @@ def test_paginated_list_uploads(foss: Fossology, upload: Upload, test_file_path: def test_list_uploads_500_error(foss: Fossology, foss_server: str, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads", + f"{foss_server}/api/v2/uploads", status=500, ) with pytest.raises(FossologyApiError): @@ -301,7 +301,7 @@ def test_download_upload_authorization_error( ): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/download", + f"{foss_server}/api/v2/uploads/{upload.id}/download", status=403, ) with pytest.raises(AuthorizationError) as excinfo: @@ -313,7 +313,7 @@ def test_download_upload_authorization_error( def test_download_upload_error(foss_server: str, foss: Fossology, upload: Upload): responses.add( responses.GET, - f"{foss_server}/api/v1/uploads/{upload.id}/download", + f"{foss_server}/api/v2/uploads/{upload.id}/download", status=401, ) with pytest.raises(FossologyApiError) as excinfo: diff --git a/tests/test_users.py b/tests/test_users.py index 2c6a044..359285e 100644 --- a/tests/test_users.py +++ b/tests/test_users.py @@ -88,6 +88,8 @@ def test_unknown_user(foss: Fossology): def test_list_users(foss: Fossology): # Fixture created_foss_user creates a new user for the test session + # If the whole test suite runs, a second user is created + # Running this test only will result in 1 user users = foss.list_users() assert len(users) == 2 @@ -96,7 +98,7 @@ def test_list_users(foss: Fossology): def test_get_self_error(foss_server: str, foss: Fossology): responses.add( responses.GET, - f"{foss_server}/api/v1/users/self", + f"{foss_server}/api/v2/users/self", status=500, ) with pytest.raises(FossologyApiError): @@ -109,7 +111,7 @@ def test_get_self_with_agents( ): user = foss_user responses.add( - responses.GET, f"{foss_server}/api/v1/users/self", status=200, json=user + responses.GET, f"{foss_server}/api/v2/users/self", status=200, json=user ) user_from_api = foss.get_self() assert user_from_api.agents.to_dict() == foss_user_agents @@ -121,7 +123,7 @@ def test_detail_user_with_agents( ): user = foss_user responses.add( - responses.GET, f"{foss_server}/api/v1/users/{user['id']}", status=200, json=user + responses.GET, f"{foss_server}/api/v2/users/{user['id']}", status=200, json=user ) user_from_api = foss.detail_user(user["id"]) assert user_from_api.agents.to_dict() == foss_user_agents @@ -132,14 +134,14 @@ def test_list_users_with_agents( foss_server: str, foss: Fossology, foss_user: dict, foss_user_agents: dict ): users = [foss_user] - responses.add(responses.GET, f"{foss_server}/api/v1/users", status=200, json=users) + responses.add(responses.GET, f"{foss_server}/api/v2/users", status=200, json=users) users_from_api = foss.list_users() assert users_from_api[0].agents.to_dict() == foss_user_agents @responses.activate def test_list_users_error(foss_server: str, foss: Fossology): - responses.add(responses.GET, f"{foss_server}/api/v1/users", status=404) + responses.add(responses.GET, f"{foss_server}/api/v2/users", status=404) with pytest.raises(FossologyApiError) as excinfo: foss.list_users() assert f"Unable to get a list of users from {foss_server}" in str(excinfo.value) @@ -156,8 +158,8 @@ def test_detail_user(foss: Fossology): @responses.activate def test_delete_user(foss_server: str, foss: Fossology): user = Mock(name="Test User", id=secrets.randbelow(1000)) - responses.add(responses.DELETE, f"{foss_server}/api/v1/users/{user.id}", status=202) - responses.add(responses.DELETE, f"{foss_server}/api/v1/users/{user.id}", status=404) + responses.add(responses.DELETE, f"{foss_server}/api/v2/users/{user.id}", status=202) + responses.add(responses.DELETE, f"{foss_server}/api/v2/users/{user.id}", status=404) assert not foss.delete_user(user) with pytest.raises(FossologyApiError) as excinfo: foss.delete_user(user)