Skip to content

Commit

Permalink
fix: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Aug 17, 2024
1 parent cd69a41 commit dff578f
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions tests/api/v1/endpoints/test_cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions tests/api/v1/endpoints/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions tests/api/v1/endpoints/test_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions tests/api/v1/endpoints/test_vulns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/crud/test_crud_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions tests/crud/test_crud_vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/schemas/osv/test_fixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mihama import schemas


@pytest.fixture()
@pytest.fixture
def vuln():
# introduced: 0
# fixed: 0.0.9
Expand Down
2 changes: 1 addition & 1 deletion tests/schemas/osv/test_last_affected.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mihama import schemas


@pytest.fixture()
@pytest.fixture
def vuln():
# introduced: 0
# last_affected: 4.1.0
Expand Down
4 changes: 2 additions & 2 deletions tests/schemas/osv/test_multi_packages_fixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/schemas/osv/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/schemas/test_cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion tests/schemas/test_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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/[email protected]")
Expand Down

0 comments on commit dff578f

Please sign in to comment.