tests: add integration tests for all API methods

parent a0d030c0
...@@ -165,8 +165,8 @@ class BugzillaInfoElementModel(BaseModel): ...@@ -165,8 +165,8 @@ class BugzillaInfoElementModel(BaseModel):
version: str | None version: str | None
platform: str | None platform: str | None
component: str component: str
source_package_name: str source_package_name: str | None = None
binary_package_name: str binary_package_name: str | None = None
assignee: str | None = None assignee: str | None = None
reporter: str reporter: str
summary: str summary: str
......
import asyncio
import pytest
import pytest_asyncio
from altrepo import ALTRepo
from altrepo.api.types import Branch
@pytest_asyncio.fixture(autouse=True)
async def rate_limit():
yield
await asyncio.sleep(0.5)
@pytest_asyncio.fixture(scope="session")
async def client():
async with ALTRepo() as c:
yield c
@pytest_asyncio.fixture(scope="session")
async def pkghash(client):
found = await client.api.site.find_packages("firefox", branch=Branch.sisyphus)
return int(found.packages[0].versions[0].pkghash)
@pytest_asyncio.fixture(scope="session")
async def task_id(client):
result = await client.api.task.progress.find_tasks(
input=["fiersik"], branch=Branch.sisyphus, by_package=False
)
done = [t for t in result.tasks if t.task_state == "DONE"]
return done[0].task_id
@pytest_asyncio.fixture(scope="session")
async def image_uuid(client):
images = await client.api.image.iso.all_images()
return images.images[0].uuid
@pytest_asyncio.fixture(scope="session")
async def errata_id(client):
erratas = await client.api.errata.search(branch=Branch.p11, name="openssh")
return erratas.erratas[0].id
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_groups(client):
result = await client.api.acl.groups(Branch.sisyphus)
assert result
async def test_by_packages(client):
result = await client.api.acl.by_packages(Branch.sisyphus, ["firefox"])
assert result.packages
async def test_maintainer_groups(client):
result = await client.api.acl.maintainer_groups("rider")
assert result.branches
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_bugzilla_by_maintainer(client):
result = await client.api.bug.bugzilla_by_maintainer("fiersik")
assert result is None or result.bugs is not None
async def test_bugzilla_by_package(client):
result = await client.api.bug.bugzilla_by_package("firefox")
assert result
async def test_bugzilla_by_image_edition(client):
result = await client.api.bug.bugzilla_by_image_edition(Branch.p11, "alt-workstation")
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_backport_helper(client):
result = await client.api.dependencies.backport_helper(
Branch.sisyphus, Branch.p11, ["ocaml"]
)
assert result.count >= 0
async def test_binary_package_dependencies(client, pkghash):
result = await client.api.dependencies.binary_package_dependencies(pkghash)
assert result
async def test_fast_lookup(client):
result = await client.api.dependencies.fast_lookup(Branch.sisyphus, "libc.so")
assert result
async def test_packages_by_dependency(client):
result = await client.api.dependencies.packages_by_dependency(
Branch.sisyphus, "libc.so.6"
)
assert result
async def test_source_package_dependencies(client, pkghash):
result = await client.api.dependencies.source_package_dependencies(
pkghash, Branch.sisyphus
)
assert result.dependencies
async def test_what_depends_src(client):
result = await client.api.dependencies.what_depends_src("firefox", Branch.sisyphus)
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_advisory(client):
result = await client.api.errata.advisory(branch=Branch.p11, limit=3)
assert result.erratas
async def test_branches_updates(client):
erratas = await client.api.errata.search(branch=Branch.p11, name="openssh")
errata_id = erratas.erratas[0].id
result = await client.api.errata.packages_updates([errata_id])
assert result
async def test_errata_branches(client):
result = await client.api.errata.errata_branches()
assert result.branches
async def test_export_oval_branches(client):
result = await client.api.errata.export.oval.branches()
assert result.branches
async def test_export_oval_info(client):
result = await client.api.errata.export.oval.info(Branch.p11)
assert isinstance(result, bytes)
assert len(result) > 0
async def test_find_erratas(client):
result = await client.api.errata.find_erratas(input=["openssh"])
assert result.erratas
async def test_ids(client):
result = await client.api.errata.ids()
assert result
async def test_packages_updates(client, errata_id):
result = await client.api.errata.packages_updates([errata_id])
assert result
async def test_search(client):
result = await client.api.errata.search(branch=Branch.p11, name="openssh")
assert result.erratas
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_beehive_ftbfs(client):
result = await client.api.export.beehive.ftbfs(Branch.sisyphus)
assert result.ftbfs
async def test_translation_packages_po_files(client):
result = await client.api.export.translation.packages_po_files([Branch.sisyphus])
assert isinstance(result, bytes)
assert len(result) > 0
async def test_branch_binary_packages(client):
result = await client.api.export.branch_binary_packages(Branch.sisyphus)
assert result.packages
async def test_branch_tree(client):
result = await client.api.export.branch_tree()
assert result
async def test_repology(client):
result = await client.api.export.repology(Branch.sisyphus)
assert result
async def test_sitemap_packages(client):
result = await client.api.export.sitemap_packages(Branch.sisyphus)
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_packages_by_file(client):
result = await client.api.file.packages_by_file(Branch.sisyphus, "/usr/bin/python3")
assert result.packages
async def test_search(client):
result = await client.api.file.search(Branch.sisyphus, "nginx.conf")
assert result.files
async def test_fast_lookup(client):
result = await client.api.file.fast_lookup(Branch.sisyphus, "nginx")
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_iso_all_images(client):
result = await client.api.image.iso.all_images()
assert result.images
async def test_active_images(client):
result = await client.api.image.active_images(branch=Branch.p11)
assert result.images
async def test_find_images_by_package_name(client):
result = await client.api.image.find_images_by_package_name("firefox")
assert result
async def test_image_info(client):
result = await client.api.image.image_info(branch=Branch.p11)
assert result
async def test_image_packages(client, image_uuid):
result = await client.api.image.image_packages(image_uuid)
assert result
async def test_image_packageset(client):
result = await client.api.image.image_packageset()
assert result
async def test_image_status_get(client):
result = await client.api.image.image_status_get()
assert result
async def test_image_tag_status_get(client):
result = await client.api.image.image_tag_status_get(branch=Branch.p11)
assert result
import pytest
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_license_text(client):
result = await client.api.license.license_text()
assert isinstance(result, str)
assert len(result) > 0
async def test_info(client):
result = await client.api.license.info("GPL-2.0")
assert result
async def test_tokens(client):
result = await client.api.license.tokens("GPL-2.0")
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_package_info(client):
result = await client.api.package.package_info("firefox", branch=Branch.sisyphus)
assert result.packages
async def test_build_dependency_set(client):
result = await client.api.package.build_dependency_set(Branch.sisyphus, ["firefox"])
assert result.packages
async def test_find_packageset(client):
result = await client.api.package.find_packageset(["firefox"])
assert result
async def test_maintainer_score(client):
result = await client.api.package.maintainer_score(Branch.sisyphus, "firefox")
assert result
@pytest.mark.xfail(reason="API bug: request_args returns int instead of dict")
async def test_package_files(client, pkghash):
result = await client.api.package.package_files(pkghash)
assert result.files
async def test_repocop(client):
result = await client.api.package.repocop(Branch.sisyphus, "firefox")
assert result
async def test_specfile_by_hash(client, pkghash):
result = await client.api.package.specfile_by_hash(pkghash)
assert result
async def test_specfile_by_name(client):
result = await client.api.package.specfile_by_name(Branch.sisyphus, "firefox")
assert result
async def test_what_depends_src(client):
result = await client.api.package.what_depends_src(["firefox"], Branch.sisyphus)
assert result.dependencies
async def test_unpackaged_dirs(client):
result = await client.api.package.unpackaged_dirs(Branch.sisyphus, "fiersik")
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_active_packagesets(client):
result = await client.api.packageset.active_packagesets()
assert result.packagesets
async def test_repository_statistics(client):
result = await client.api.packageset.repository_statistics(Branch.sisyphus)
assert result
async def test_compare_packagesets(client):
result = await client.api.packageset.compare_packagesets(Branch.sisyphus, Branch.p11)
assert result.packages
async def test_maintainer_scores(client):
result = await client.api.packageset.maintainer_scores(Branch.sisyphus)
assert result
async def test_pkgset_status_get(client):
result = await client.api.packageset.pkgset_status_get()
assert result
async def test_repository_packages(client):
result = await client.api.packageset.repository_packages(Branch.sisyphus)
assert result.packages
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_all_maintainers(client):
result = await client.api.site.all_maintainers(Branch.sisyphus)
assert result
async def test_all_maintainers_with_nicknames(client):
result = await client.api.site.all_maintainers_with_nicknames(Branch.sisyphus)
assert result
async def test_find_source_package(client):
result = await client.api.site.find_source_package(Branch.sisyphus, "firefox")
assert result
async def test_maintainer_info(client):
result = await client.api.site.maintainer_info(Branch.sisyphus, "fiersik")
assert result.information
async def test_package_info(client, pkghash):
result = await client.api.site.package_info(Branch.sisyphus, pkghash)
assert result
async def test_pkghash_by_name(client):
result = await client.api.site.pkghash_by_name(Branch.sisyphus, "firefox")
assert result.pkghash
async def test_watch_by_maintainer(client):
result = await client.api.site.watch_by_maintainer("fiersik")
assert result is None or result.packages is not None
async def test_all_pkgset_archs(client):
result = await client.api.site.all_pkgset_archs(Branch.sisyphus)
assert result
async def test_all_pkgset_archs_with_src_count(client):
result = await client.api.site.all_pkgset_archs_with_src_count(Branch.sisyphus)
assert result
async def test_all_pkgsets(client):
result = await client.api.site.all_pkgsets()
assert result.packagesets
async def test_all_pkgsets_summary(client):
result = await client.api.site.all_pkgsets_summary()
assert result
async def test_all_pkgsets_with_src_count(client):
result = await client.api.site.all_pkgsets_with_src_count()
assert result.packagesets
async def test_beehive_errors_by_maintainer(client):
result = await client.api.site.beehive_errors_by_maintainer(Branch.sisyphus, "fiersik")
assert result
async def test_binary_package_archs_and_versions(client):
result = await client.api.site.binary_package_archs_and_versions(Branch.sisyphus, "firefox")
assert result
@pytest.mark.xfail(reason="API bug: request_args returns int instead of dict")
async def test_binary_package_scripts(client):
h = await client.api.site.pkghash_by_binary_name(Branch.sisyphus, "python3", "x86_64")
result = await client.api.site.binary_package_scripts(int(h.pkghash))
assert result
async def test_deleted_package_info(client):
result = await client.api.site.deleted_package_info(Branch.sisyphus, "altrepo-api")
assert result
async def test_fast_packages_search_lookup(client):
result = await client.api.site.fast_packages_search_lookup(["firefox"])
assert result
async def test_find_packages(client):
result = await client.api.site.find_packages("firefox", branch=Branch.sisyphus)
assert result.packages
async def test_last_packages(client):
result = await client.api.site.last_packages(Branch.sisyphus)
assert result
async def test_last_packages_by_branch(client):
result = await client.api.site.last_packages_by_branch(Branch.sisyphus)
assert result
async def test_last_packages_by_tasks(client):
result = await client.api.site.last_packages_by_tasks(Branch.sisyphus)
assert result
async def test_last_packages_with_cve_fixed(client):
result = await client.api.site.last_packages_with_cve_fixed(Branch.sisyphus)
assert result
async def test_maintainer_branches(client):
result = await client.api.site.maintainer_branches("fiersik")
assert result
async def test_maintainer_packages(client):
result = await client.api.site.maintainer_packages(Branch.sisyphus, "fiersik")
assert result.packages
async def test_package_changelog(client, pkghash):
result = await client.api.site.package_changelog(pkghash)
assert result
async def test_package_downloads(client, pkghash):
result = await client.api.site.package_downloads(pkghash, Branch.sisyphus)
assert result
async def test_package_downloads_src(client, pkghash):
result = await client.api.site.package_downloads_src(pkghash, Branch.sisyphus)
assert result
async def test_package_info_brief(client, pkghash):
result = await client.api.site.package_info_brief(pkghash)
assert result
async def test_package_log_bin(client):
h = await client.api.site.pkghash_by_binary_name(Branch.sisyphus, "python3", "x86_64")
result = await client.api.site.package_log_bin(int(h.pkghash))
assert result
async def test_package_misconflict(client):
result = await client.api.site.package_misconflict(3138908692359206701, Branch.p11)
assert result
async def test_package_name_from_repology(client):
result = await client.api.site.package_name_from_repology(Branch.sisyphus, "firefox")
assert result
async def test_package_nvr_by_hash(client, pkghash):
result = await client.api.site.package_nvr_by_hash(pkghash)
assert result
async def test_package_versions(client):
result = await client.api.site.package_versions("firefox")
assert result.versions
async def test_package_versions_from_tasks(client):
result = await client.api.site.package_versions_from_tasks("firefox")
assert result
async def test_packagesets_by_hash(client, pkghash):
result = await client.api.site.packagesets_by_hash(pkghash)
assert result
async def test_pkgset_categories_count(client):
result = await client.api.site.pkgset_categories_count(Branch.sisyphus)
assert result
async def test_pkgsets_summary_status(client):
result = await client.api.site.pkgsets_summary_status()
assert result
async def test_repocop_by_maintainer(client):
result = await client.api.site.repocop_by_maintainer(Branch.sisyphus, "fiersik")
assert result
async def test_repository_packages(client):
result = await client.api.site.repository_packages(Branch.sisyphus)
assert result
async def test_source_package_versions(client):
result = await client.api.site.source_package_versions("firefox")
assert result.versions
async def test_tasks_by_maintainer(client):
result = await client.api.site.tasks_by_maintainer(Branch.sisyphus, "fiersik")
assert result
async def test_tasks_by_package(client):
result = await client.api.site.tasks_by_package("firefox")
assert result
async def test_tasks_history(client):
result = await client.api.site.tasks_history()
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_progress_find_tasks(client):
result = await client.api.task.progress.find_tasks(
input=["fiersik"], branch=Branch.sisyphus, by_package=False
)
assert result.tasks
async def test_progress_task_info(client, task_id):
result = await client.api.task.progress.task_info(task_id)
assert result
async def test_progress_all_packagesets(client):
result = await client.api.task.progress.all_packagesets()
assert result
async def test_progress_all_tasks_branches(client):
result = await client.api.task.progress.all_tasks_branches()
assert result
async def test_progress_find_tasks_lookup(client):
result = await client.api.task.progress.find_tasks_lookup(["fiersik"])
assert result
async def test_progress_last_tasks(client):
result = await client.api.task.progress.last_tasks()
assert result.tasks
async def test_build_dependency_set(client, task_id):
result = await client.api.task.build_dependency_set(task_id)
assert result.id == task_id
async def test_task_info(client, task_id):
result = await client.api.task.task_info(task_id)
assert result.id == task_id
async def test_task_diff(client, task_id):
result = await client.api.task.task_diff(task_id)
assert result
async def test_what_depends_src(client, task_id):
result = await client.api.task.what_depends_src(task_id)
assert result.id == task_id
import pytest
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_cve_info(client):
result = await client.api.vuln.cve.info("CVE-2024-6387")
assert result.vuln_info.id == "CVE-2024-6387"
async def test_cve_fixes(client):
result = await client.api.vuln.cve.fixes("CVE-2024-6387")
assert result.packages
@pytest.mark.skip(reason="requires CVE with excluded packages data")
async def test_cve_excluded(client):
result = await client.api.vuln.cve.excluded("CVE-2023-44487")
assert result
async def test_bdu_info(client):
result = await client.api.vuln.bdu.info("BDU:2024-04914")
assert result.vuln_info.id == "BDU:2024-04914"
async def test_bdu_fixes(client):
result = await client.api.vuln.bdu.fixes("BDU:2024-04914")
assert result
async def test_ghsa_info(client):
result = await client.api.vuln.ghsa.info("GHSA-c2qf-rxjj-qqgw")
assert result.vuln_info.id == "GHSA-c2qf-rxjj-qqgw"
async def test_ghsa_fixes(client):
result = await client.api.vuln.ghsa.fixes("GHSA-jfh8-c2jp-5v3q")
assert result
async def test_task(client):
result = await client.api.vuln.task(351911)
assert result
import pytest
from altrepo.api.types import Branch
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_load_and_has_file(client):
await client.appstream.data.load_by_branch(Branch.sisyphus, "latest")
assert client.appstream.data.has_file(Branch.sisyphus)
async def test_id_by_pkgname(client):
await client.appstream.data.load_by_branch(Branch.sisyphus, "latest")
result = client.appstream.package.id_by_pkgname("firefox", Branch.sisyphus)
assert result is not None
import pytest
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_news_urls(client):
result = await client.parser.news.news_urls()
assert result
async def test_sisyphus(client):
result = await client.parser.news.sisyphus()
assert result is None or result.added is not None or result.updated is not None
async def test_ftbfs(client):
result = await client.parser.packages.ftbfs()
assert isinstance(result, list)
async def test_watch_by_maintainer(client):
result = await client.parser.packages.watch_by_maintainer("fiersik", "by-acl")
assert isinstance(result, list)
async def test_watch_total(client):
result = await client.parser.packages.watch_total()
assert isinstance(result, list)
assert len(result) > 0
import pytest
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_health(client):
result = await client.taskoteka.health()
assert result.status == "ok"
assert result.total_tasks > 0
async def test_owners(client):
result = await client.taskoteka.owners()
assert isinstance(result, list)
assert len(result) > 0
async def test_tasks_list(client):
result = await client.taskoteka.tasks()
assert isinstance(result, list)
async def test_tasks_by_id(client):
tasks = await client.taskoteka.tasks(state="DONE")
if tasks:
task = await client.taskoteka.tasks(task_id=tasks[0].id)
assert task.taskid == tasks[0].id
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment