Skip to content

Commit

Permalink
feat(latest): test against latest, enable all valid tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deveaud-m committed Nov 14, 2023
1 parent a683414 commit 876a9b6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/fossologytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
test-latest:
name: Integration Tests (latest Fossology - 4.3.0)
name: Integration Tests (latest Fossology - 4.x)
runs-on: ubuntu-latest

container:
Expand All @@ -20,7 +20,7 @@ jobs:

services:
fossology:
image: fossology/fossology:4.3.0
image: fossology/fossology:latest
ports:
- 8081:80
volumes:
Expand Down
22 changes: 1 addition & 21 deletions tests/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
from fossology.obj import FileInfo, Upload


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_item_info(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
info: FileInfo = foss.item_info(upload_with_jobs, files[0].uploadTreeId)
assert info.meta_info["fileUploadOrigin"] == "base-files_11.tar.xz"


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_item_info_with_unknown_item_raises_api_error(
foss: Fossology, upload_with_jobs: Upload
):
Expand All @@ -26,7 +24,6 @@ def test_item_info_with_unknown_item_raises_api_error(
assert f"Upload {upload_with_jobs.id} or item 1 not found" in str(excinfo.value)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
@responses.activate
def test_item_info_500_error(
foss: Fossology, foss_server: str, upload_with_jobs: Upload
Expand All @@ -39,12 +36,11 @@ def test_item_info_500_error(
with pytest.raises(FossologyApiError) as excinfo:
foss.item_info(upload_with_jobs, 1)
assert (
f"API error while getting info for item 1 from upload {upload_with_jobs.uploadname}."
f"API error while getting info for item 1 from upload {upload_with_jobs.uploadname}"
in excinfo.value.message
)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_item_copyrights(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
num_copyrights = foss.item_copyrights(
Expand All @@ -53,7 +49,6 @@ def test_item_copyrights(foss: Fossology, upload_with_jobs: Upload):
assert num_copyrights == 0


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_item_copyrights_with_unknown_item_raises_api_error(
foss: Fossology, upload_with_jobs: Upload
):
Expand All @@ -62,7 +57,6 @@ def test_item_copyrights_with_unknown_item_raises_api_error(
assert f"Upload {upload_with_jobs.id} or item 1 not found" in str(excinfo.value)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
@responses.activate
def test_item_copyrights_500_error(
foss: Fossology, foss_server: str, upload_with_jobs: Upload
Expand All @@ -80,14 +74,12 @@ def test_item_copyrights_500_error(
)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_clearing_history(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
history = foss.get_clearing_history(upload_with_jobs, files[0].uploadTreeId)
assert not history


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_clearing_history_with_unknown_item_raises_api_error(
foss: Fossology, upload_with_jobs: Upload
):
Expand All @@ -96,7 +88,6 @@ def test_upload_get_clearing_history_with_unknown_item_raises_api_error(
assert f"Upload {upload_with_jobs.id} or item 1 not found" in str(excinfo.value)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
@responses.activate
def test_upload_get_clearing_history_500_error(
foss: Fossology, foss_server: str, upload_with_jobs: Upload
Expand All @@ -114,14 +105,12 @@ def test_upload_get_clearing_history_500_error(
)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_bulk_history(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
history = foss.get_bulk_history(upload_with_jobs, files[0].uploadTreeId)
assert not history


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_bulk_history_with_unknown_item_raises_api_error(
foss: Fossology, upload_with_jobs: Upload
):
Expand All @@ -130,7 +119,6 @@ def test_upload_get_bulk_history_with_unknown_item_raises_api_error(
assert f"Upload {upload_with_jobs.id} or item 1 not found" in str(excinfo.value)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
@responses.activate
def test_upload_get_bulk_history_500_error(
foss: Fossology, foss_server: str, upload_with_jobs: Upload
Expand All @@ -148,7 +136,6 @@ def test_upload_get_bulk_history_500_error(
)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_schedule_bulk_scan(
foss: Fossology, upload_with_jobs: Upload, foss_bulk_scan_spec: dict
):
Expand All @@ -162,7 +149,6 @@ def test_upload_schedule_bulk_scan(
assert history[0].addedLicenses == ["MIT"]


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_schedule_bulk_scan_with_unknown_item_raises_api_error(
foss: Fossology, upload_with_jobs: Upload, foss_bulk_scan_spec: dict
):
Expand All @@ -171,7 +157,6 @@ def test_schedule_bulk_scan_with_unknown_item_raises_api_error(
assert f"Upload {upload_with_jobs.id} or item 1 not found" in str(excinfo.value)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
@responses.activate
def test_schedule_bulk_scan_500_error(
foss: Fossology,
Expand All @@ -192,14 +177,12 @@ def test_schedule_bulk_scan_500_error(
)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_prev_next(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
prev_next = foss.get_prev_next(upload_with_jobs, files[0].uploadTreeId)
assert prev_next


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_prev_next_with_licenses(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
prev_next = foss.get_prev_next(
Expand All @@ -208,7 +191,6 @@ def test_upload_get_prev_next_with_licenses(foss: Fossology, upload_with_jobs: U
assert prev_next


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_prev_next_no_clearing(foss: Fossology, upload_with_jobs: Upload):
files, _ = foss.search(license="BSD")
prev_next = foss.get_prev_next(
Expand All @@ -217,7 +199,6 @@ def test_upload_get_prev_next_no_clearing(foss: Fossology, upload_with_jobs: Upl
assert prev_next


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
def test_upload_get_prev_next_with_unknown_item_raises_api_error(
foss: Fossology, upload_with_jobs: Upload
):
Expand All @@ -226,7 +207,6 @@ def test_upload_get_prev_next_with_unknown_item_raises_api_error(
assert f"Upload {upload_with_jobs.id} or item 1 not found" in str(excinfo.value)


@pytest.mark.skip(reason="Not yet released, waiting for API version 1.6.0")
@responses.activate
def test_upload_get_prev_next_500_error(
foss: Fossology, foss_server: str, upload_with_jobs: Upload
Expand Down
10 changes: 5 additions & 5 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_schedule_jobs(
assert job.name == upload_with_jobs.uploadname

jobs, _ = foss.list_jobs(upload=upload_with_jobs)
assert len(jobs) == 3
assert len(jobs) == 4

job = foss.detail_job(jobs[1].id, wait=True, timeout=30)
assert job.status == JobStatus.COMPLETED.value
Expand Down Expand Up @@ -102,16 +102,16 @@ def test_paginated_list_jobs(foss: Fossology, upload_with_jobs: Upload):
jobs, total_pages = foss.list_jobs(
upload=upload_with_jobs, page_size=1, all_pages=True
)
assert len(jobs) == 3
assert total_pages == 3
assert len(jobs) == 4
assert total_pages == 4

jobs, total_pages = foss.list_jobs(upload=upload_with_jobs, page_size=1, page=1)
assert len(jobs) == 1
assert total_pages == 3
assert total_pages == 4

jobs, total_pages = foss.list_jobs(upload=upload_with_jobs, page_size=1, page=2)
assert len(jobs) == 1
assert total_pages == 3
assert total_pages == 4

jobs, total_pages = foss.list_jobs(upload=upload_with_jobs, page_size=2, page=1)
assert len(jobs) == 2
Expand Down
38 changes: 8 additions & 30 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,19 @@
from fossology.obj import Upload


# See: https://github.com/fossology/fossology/pull/2390
@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
def test_search_nogroup(foss: Fossology):
with pytest.raises(FossologyApiError) as excinfo:
foss.search(searchType=SearchTypes.ALLFILES, filename="GPL%", group="test")
assert "Searching for group test not authorized" in str(excinfo.value)
assert "Unable to get a result with the given search criteria" in str(excinfo.value)


@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
def test_search(foss: Fossology, upload: Upload):
search_result = foss.search(searchType=SearchTypes.ALLFILES, filename="GPL%")
search_result, _ = foss.search(searchType=SearchTypes.ALLFILES, filename="GPL%")
assert search_result


@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
def test_search_nothing_found(foss: Fossology, upload: Upload):
search_result = foss.search(
search_result, _ = foss.search(
searchType=SearchTypes.ALLFILES,
filename="test%",
tag="test",
Expand All @@ -46,32 +36,23 @@ def test_search_nothing_found(foss: Fossology, upload: Upload):
assert search_result == []


@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
def test_search_directory(foss: Fossology, upload: Upload):
search_result = foss.search(
searchType=SearchTypes.DIRECTORIES,
search_result, _ = foss.search(
searchType=SearchTypes.DIRECTORY,
filename="share",
)
assert search_result
assert not search_result


@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
def test_search_upload(foss: Fossology, upload: Upload):
search_result = foss.search(
search_result, _ = foss.search(
searchType=SearchTypes.ALLFILES,
upload=upload,
filename="share",
)
assert search_result


@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
def test_search_upload_does_not_exist(foss: Fossology):
hash = {"sha1": "", "md5": "", "sha256": "", "size": ""}
fake_upload = Upload(
Expand All @@ -83,17 +64,14 @@ def test_search_upload_does_not_exist(foss: Fossology):
"2020-12-30",
hash=hash,
)
search_result = foss.search(
search_result, _ = foss.search(
searchType=SearchTypes.ALLFILES,
upload=fake_upload,
filename="share",
)
assert not search_result


@pytest.mark.skip(
reason="current Fossology version has a bug, /search is not supported, fixed in 4.3.0"
)
@responses.activate
def test_search_error(foss_server: str, foss: Fossology):
responses.add(responses.GET, f"{foss_server}/api/v1/search", status=404)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_upload_licenses_copyrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
def test_upload_licenses(foss: Fossology, upload_with_jobs: Upload):
# Default agent "nomos"
licenses = foss.upload_licenses(upload_with_jobs)
assert len(licenses) == 56
assert len(licenses) == 50


def test_upload_licenses_with_containers(foss: Fossology, upload_with_jobs: Upload):
licenses = foss.upload_licenses(upload_with_jobs, containers=True)
assert len(licenses) == 56
assert len(licenses) == 50


def test_upload_licenses_agent_ojo(foss: Fossology, upload_with_jobs: Upload):
Expand All @@ -33,7 +33,7 @@ def test_upload_licenses_agent_monk(foss: Fossology, upload_with_jobs: Upload):

def test_upload_licenses_and_copyrights(foss: Fossology, upload_with_jobs: Upload):
licenses = foss.upload_licenses(upload_with_jobs, copyright=True)
assert len(licenses) == 56
assert len(licenses) == 50


def test_upload_licenses_with_unknown_group_raises_authorization_error(
Expand Down

0 comments on commit 876a9b6

Please sign in to comment.