Skip to content

Commit

Permalink
fixing async tests
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Dec 12, 2023
1 parent 17991c4 commit 59efe51
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 243 deletions.
2 changes: 1 addition & 1 deletion backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ isort = "*"
mypy = "*"
pip = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-cov = "*"
pytest-anyio = "*"
pytest-faker = "*"
pytest-httpx = "*"
pytest-subprocess = "*"
Expand Down
188 changes: 82 additions & 106 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions backend/tests/api/api_v1/test_acmgseqvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def acmgseqvar_post_data() -> dict[str, Any]:
}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_create_acmgseqvar(
db_session: AsyncSession,
Expand All @@ -51,7 +51,7 @@ async def test_create_acmgseqvar(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_create_acmgseqvar_superuser(
db_session: AsyncSession,
Expand All @@ -72,7 +72,7 @@ async def test_create_acmgseqvar_superuser(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_create_acmgseqvar_anon(
db_session: AsyncSession, client: TestClient, acmgseqvar_post_data: dict[str, Any]
):
Expand All @@ -86,7 +86,7 @@ async def test_create_acmgseqvar_anon(
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_create_acmgseqvar_invalid_data(
db_session: AsyncSession,
Expand All @@ -102,7 +102,7 @@ async def test_create_acmgseqvar_invalid_data(
assert response.status_code == 422


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_create_acmgseqvar_invalid_enums(
db_session: AsyncSession,
Expand All @@ -126,7 +126,7 @@ async def test_create_acmgseqvar_invalid_enums(
# ------------------------------------------------------------------------------


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_list_all_acmgseqvars(
db_session: AsyncSession,
Expand All @@ -151,7 +151,7 @@ async def test_list_all_acmgseqvars(
assert content == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_list_all_acmgseqvars_superuser(
db_session: AsyncSession,
Expand All @@ -178,7 +178,7 @@ async def test_list_all_acmgseqvars_superuser(
assert content[0]["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_list_all_acmgseqvars_anon(db_session: AsyncSession, client: TestClient):
"""Test listing all acmgseqvars as anonymous user."""
_ = db_session
Expand All @@ -189,7 +189,7 @@ async def test_list_all_acmgseqvars_anon(db_session: AsyncSession, client: TestC
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_list_all_no_acmgseqvars(
db_session: AsyncSession,
Expand All @@ -211,7 +211,7 @@ async def test_list_all_no_acmgseqvars(
# ------------------------------------------------------------------------------


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_get_by_id_acmgseqvar(
db_session: AsyncSession,
Expand Down Expand Up @@ -239,7 +239,7 @@ async def test_get_by_id_acmgseqvar(
assert content == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_get_by_id_acmgseqvar_superuser(
db_session: AsyncSession,
Expand Down Expand Up @@ -269,7 +269,7 @@ async def test_get_by_id_acmgseqvar_superuser(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_get_by_id_acmgseqvar_anon(db_session: AsyncSession, client: TestClient):
"""Test getting a acmgseqvar as anonymous user."""
_ = db_session
Expand All @@ -280,7 +280,7 @@ async def test_get_by_id_acmgseqvar_anon(db_session: AsyncSession, client: TestC
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_get_acmgseqvar_by_invalid_id(
db_session: AsyncSession,
Expand All @@ -301,7 +301,7 @@ async def test_get_acmgseqvar_by_invalid_id(
# ------------------------------------------------------------------------------


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_list_acmgseqvars(
db_session: AsyncSession,
Expand All @@ -328,7 +328,7 @@ async def test_list_acmgseqvars(
assert content[0]["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_list_acmgseqvars_superuser(
db_session: AsyncSession,
Expand All @@ -355,7 +355,7 @@ async def test_list_acmgseqvars_superuser(
assert content[0]["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_list_acmgseqvars_anon(db_session: AsyncSession, client: TestClient):
"""Test listing acmgseqvars as anonymous user."""
_ = db_session
Expand All @@ -366,7 +366,7 @@ async def test_list_acmgseqvars_anon(db_session: AsyncSession, client: TestClien
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_list_no_acmgseqvars(
db_session: AsyncSession,
Expand All @@ -388,7 +388,7 @@ async def test_list_no_acmgseqvars(
# ------------------------------------------------------------------------------


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_get_acmgseqvar(
db_session: AsyncSession,
Expand All @@ -415,7 +415,7 @@ async def test_get_acmgseqvar(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_get_acmgseqvar_superuser(
db_session: AsyncSession,
Expand All @@ -442,7 +442,7 @@ async def test_get_acmgseqvar_superuser(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_get_acmgseqvar_anon(db_session: AsyncSession, client: TestClient):
"""Test getting a acmgseqvar as anonymous user."""
_ = db_session
Expand All @@ -453,7 +453,7 @@ async def test_get_acmgseqvar_anon(db_session: AsyncSession, client: TestClient)
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_get_no_acmgseqvar(
db_session: AsyncSession,
Expand Down Expand Up @@ -491,7 +491,7 @@ def acmgseqvar_update_data() -> dict[str, Any]:
}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_update_acmgseqvar(
db_session: AsyncSession,
Expand Down Expand Up @@ -520,7 +520,7 @@ async def test_update_acmgseqvar(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_update_acmgseqvar_superuser(
db_session: AsyncSession,
Expand Down Expand Up @@ -549,7 +549,7 @@ async def test_update_acmgseqvar_superuser(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_update_acmgseqvar_anon(
db_session: AsyncSession, client: TestClient, acmgseqvar_update_data: dict[str, Any]
):
Expand All @@ -563,7 +563,7 @@ async def test_update_acmgseqvar_anon(
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_update_acmgseqvar_patch(
db_session: AsyncSession,
Expand Down Expand Up @@ -592,7 +592,7 @@ async def test_update_acmgseqvar_patch(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_update_acmgseqvar_no_acmgseqvar(
db_session: AsyncSession,
Expand All @@ -610,7 +610,7 @@ async def test_update_acmgseqvar_no_acmgseqvar(
assert response.json() == {"detail": "ACMG Sequence Variant not found"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_update_acmgseqvar_invalid_enum(
db_session: AsyncSession,
Expand Down Expand Up @@ -642,7 +642,7 @@ async def test_update_acmgseqvar_invalid_enum(
# ------------------------------------------------------------------------------


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_delete_acmgseqvar_by_id(
db_session: AsyncSession,
Expand All @@ -669,7 +669,7 @@ async def test_delete_acmgseqvar_by_id(
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_delete_acmgseqvar_by_id_superuser(
db_session: AsyncSession,
Expand Down Expand Up @@ -699,7 +699,7 @@ async def test_delete_acmgseqvar_by_id_superuser(
assert content["user"] == str(test_user.id)


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_delete_acmgseqvar_by_id_anon(db_session: AsyncSession, client: TestClient):
"""Test deleting a acmgseqvar by id as anonymous user."""
_ = db_session
Expand All @@ -710,7 +710,7 @@ async def test_delete_acmgseqvar_by_id_anon(db_session: AsyncSession, client: Te
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_delete_acmgseqvar_by_invalid_id(
db_session: AsyncSession,
Expand All @@ -731,7 +731,7 @@ async def test_delete_acmgseqvar_by_invalid_id(
# ------------------------------------------------------------------------------


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(False, False)], indirect=True)
async def test_delete_acmgseqvar(
db_session: AsyncSession,
Expand Down Expand Up @@ -763,7 +763,7 @@ async def test_delete_acmgseqvar(
assert response.status_code == 404


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_delete_acmgseqvar_superuser(
db_session: AsyncSession,
Expand Down Expand Up @@ -795,7 +795,7 @@ async def test_delete_acmgseqvar_superuser(
assert response.status_code == 404


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_delete_acmgseqvar_anon(db_session: AsyncSession, client: TestClient):
"""Test deleting a acmgseqvar as anonymous user."""
_ = db_session
Expand All @@ -806,7 +806,7 @@ async def test_delete_acmgseqvar_anon(db_session: AsyncSession, client: TestClie
assert response.json() == {"detail": "Unauthorized"}


@pytest.mark.asyncio
@pytest.mark.anyio
@pytest.mark.parametrize("test_user, client_user", [(True, True)], indirect=True)
async def test_delete_acmgseqvar_no_acmgseqvar(
db_session: AsyncSession,
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/api/api_v1/test_adminmsgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from app.core.config import settings


@pytest.mark.asyncio
@pytest.mark.anyio
async def test_adminmsgs_list(db_session: AsyncSession, client: TestClient):
"""Test proxying to annonars backend."""
_ = db_session # via ``get_db()`` dependency injection
Expand Down
Loading

0 comments on commit 59efe51

Please sign in to comment.