diff --git a/tests/api/v1/endpoints/test_cyclonedx.py b/tests/api/v1/endpoints/test_cyclonedx.py index 7d4d7b1..d40a88f 100644 --- a/tests/api/v1/endpoints/test_cyclonedx.py +++ b/tests/api/v1/endpoints/test_cyclonedx.py @@ -4,13 +4,13 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def bom(): with open("tests/fixtures/cyclonedx/example.json") as f: return schemas.CycloneDX.model_validate_json(f.read()) -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_cyclonedx(client: AsyncClient, bom: schemas.CycloneDX): res = await client.post("/v1/cyclonedx/querybatch", json=bom.model_dump()) diff --git a/tests/api/v1/endpoints/test_query.py b/tests/api/v1/endpoints/test_query.py index e25e9a5..c17324d 100644 --- a/tests/api/v1/endpoints/test_query.py +++ b/tests/api/v1/endpoints/test_query.py @@ -4,7 +4,7 @@ from mihama import schemas -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_query(client: AsyncClient, vulns: list[schemas.Vulnerability]): for v in vulns: @@ -21,7 +21,7 @@ async def test_query(client: AsyncClient, vulns: list[schemas.Vulnerability]): assert len(vulns) > 0 -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_querybatch(client: AsyncClient, vulns: list[schemas.Vulnerability]): queries = [] diff --git a/tests/api/v1/endpoints/test_spdx.py b/tests/api/v1/endpoints/test_spdx.py index 469a0cf..6a04581 100644 --- a/tests/api/v1/endpoints/test_spdx.py +++ b/tests/api/v1/endpoints/test_spdx.py @@ -4,13 +4,13 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def bom(): with open("tests/fixtures/spdx/example.json") as f: return schemas.SPDX.model_validate_json(f.read()) -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_spdx(client: AsyncClient, bom: schemas.SPDX): res = await client.post("/v1/spdx/querybatch", json=bom.model_dump()) diff --git a/tests/api/v1/endpoints/test_vulns.py b/tests/api/v1/endpoints/test_vulns.py index 9538446..9f506bb 100644 --- a/tests/api/v1/endpoints/test_vulns.py +++ b/tests/api/v1/endpoints/test_vulns.py @@ -4,7 +4,7 @@ from mihama import schemas -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_get_by_id( client: AsyncClient, @@ -15,7 +15,7 @@ async def test_get_by_id( assert res.status_code == 200 -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_search(client: AsyncClient, vulns: list[schemas.Vulnerability]): for v in vulns: for affected in v.affected: diff --git a/tests/conftest.py b/tests/conftest.py index 2aad12a..3553e99 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -64,7 +64,7 @@ async def get_es(): await es.close() -@pytest.fixture() +@pytest.fixture async def es(): async with get_es() as es: yield es @@ -81,14 +81,14 @@ async def _setup_vulns(vulns: list[schemas.Vulnerability], docker_compose): await crud.vulnerability.bulk_index(es, vulns, refresh=True) -@pytest.fixture() +@pytest.fixture def app(_setup_vulns, es: AsyncElasticsearch, docker_compose): app = create_app(set_lifespan=False) app.dependency_overrides[deps.get_es] = lambda: es return app -@pytest.fixture() +@pytest.fixture async def client(app: FastAPI): async with httpx.AsyncClient( transport=httpx.ASGITransport(app=app), # type: ignore diff --git a/tests/crud/test_crud_index.py b/tests/crud/test_crud_index.py index 6d345ff..387e39f 100644 --- a/tests/crud/test_crud_index.py +++ b/tests/crud/test_crud_index.py @@ -4,7 +4,7 @@ from mihama import crud -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("docker_compose") async def test_exists(es: AsyncElasticsearch): got = await crud.index.exists(es, index="404_not_found") diff --git a/tests/crud/test_crud_vulnerability.py b/tests/crud/test_crud_vulnerability.py index d24e9dd..9d44464 100644 --- a/tests/crud/test_crud_vulnerability.py +++ b/tests/crud/test_crud_vulnerability.py @@ -4,14 +4,14 @@ from mihama import crud, schemas -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_get(vulns: list[schemas.Vulnerability], es: AsyncElasticsearch): for v in vulns: assert await crud.vulnerability.get(es, v.id) is not None -@pytest.fixture() +@pytest.fixture def purls(vulns: list[schemas.Vulnerability]): purls: set[str] = set() for v in vulns: @@ -22,7 +22,7 @@ def purls(vulns: list[schemas.Vulnerability]): return purls -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_search_by_package_purl(purls: set[str], es: AsyncElasticsearch): for purl in purls: @@ -32,7 +32,7 @@ async def test_search_by_package_purl(purls: set[str], es: AsyncElasticsearch): assert len(vulnerabilities) > 0 -@pytest.fixture() +@pytest.fixture def package_names(vulns: list[schemas.Vulnerability]): names: set[str] = set() for v in vulns: @@ -43,7 +43,7 @@ def package_names(vulns: list[schemas.Vulnerability]): return names -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.usefixtures("_setup_vulns") async def test_search_by_package_name(package_names: set[str], es: AsyncElasticsearch): for name in package_names: diff --git a/tests/schemas/osv/test_fixed.py b/tests/schemas/osv/test_fixed.py index c01fb6d..2197557 100644 --- a/tests/schemas/osv/test_fixed.py +++ b/tests/schemas/osv/test_fixed.py @@ -3,7 +3,7 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def vuln(): # introduced: 0 # fixed: 0.0.9 diff --git a/tests/schemas/osv/test_last_affected.py b/tests/schemas/osv/test_last_affected.py index ec75e67..44306d6 100644 --- a/tests/schemas/osv/test_last_affected.py +++ b/tests/schemas/osv/test_last_affected.py @@ -3,7 +3,7 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def vuln(): # introduced: 0 # last_affected: 4.1.0 diff --git a/tests/schemas/osv/test_multi_packages_fixed.py b/tests/schemas/osv/test_multi_packages_fixed.py index 6721a3c..de93287 100644 --- a/tests/schemas/osv/test_multi_packages_fixed.py +++ b/tests/schemas/osv/test_multi_packages_fixed.py @@ -3,14 +3,14 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def vuln(): # the vulnerability has multiple packages in affected with open("tests/fixtures/advisories/multi_packages_fixed.json") as f: return schemas.Vulnerability.model_validate_json(f.read()) -@pytest.fixture() +@pytest.fixture def plone_package(): return schemas.Package(ecosystem="PyPI", name="Plone") diff --git a/tests/schemas/osv/test_versions.py b/tests/schemas/osv/test_versions.py index fd19019..f8c9ce6 100644 --- a/tests/schemas/osv/test_versions.py +++ b/tests/schemas/osv/test_versions.py @@ -3,7 +3,7 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def vuln(): # versions: 3.2 to 5.2rc5 with open("tests/fixtures/advisories/versions.json") as f: diff --git a/tests/schemas/test_cyclonedx.py b/tests/schemas/test_cyclonedx.py index c2800ce..d32aa66 100644 --- a/tests/schemas/test_cyclonedx.py +++ b/tests/schemas/test_cyclonedx.py @@ -4,7 +4,7 @@ from mihama.schemas.cyclonedx import Component -@pytest.fixture() +@pytest.fixture def nested_component(): # NOTE: it has 5 components in total (4 have purl, 1 does not have purl) with open("tests/fixtures/cyclonedx/nested_components.json") as f: @@ -16,7 +16,7 @@ def test_get_flatten_components(nested_component: Component): assert len(flatten) == 5 -@pytest.fixture() +@pytest.fixture def bom(nested_component: Component): return schemas.CycloneDX(components=[nested_component]) diff --git a/tests/schemas/test_spdx.py b/tests/schemas/test_spdx.py index 1fd61e8..cb6e603 100644 --- a/tests/schemas/test_spdx.py +++ b/tests/schemas/test_spdx.py @@ -3,7 +3,7 @@ from mihama import schemas -@pytest.fixture() +@pytest.fixture def spdx(): # this file contains one PURL package only with open("tests/fixtures/spdx/example.json") as f: diff --git a/tests/test_query.py b/tests/test_query.py index b309f74..2c4def0 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -4,7 +4,7 @@ from mihama.query import normalize_query -@pytest.fixture() +@pytest.fixture def query_with_package_with_purl_without_version(): return schemas.Query( version=None, package=schemas.QueryPackage(purl="pkg:npm/jsrsasign") @@ -18,7 +18,7 @@ def test_normalize_query_with_purl_without_version( assert normalized.version is None -@pytest.fixture() +@pytest.fixture def query_with_package_with_purl_with_version(): return schemas.Query( version=None, package=schemas.QueryPackage(purl="pkg:npm/jsrsasign@0.1.0")