diff --git a/backend/tests/tests_core/test_api_admin.py b/backend/tests/tests_core/test_api_admin.py index aec3989..821a4bd 100644 --- a/backend/tests/tests_core/test_api_admin.py +++ b/backend/tests/tests_core/test_api_admin.py @@ -12,6 +12,7 @@ async def test_hoods_unauthorized(asyncclient): assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_hoods_success(client, auth_header): - response = client.get("/api/admin/hoods/", headers=auth_header) +@pytest.mark.anyio +async def test_hoods_success(asyncclient, auth_header): + response = await asyncclient.get("/api/admin/hoods/", headers=auth_header) assert response.status_code == status.HTTP_200_OK diff --git a/backend/tests/tests_core/test_api_hoods.py b/backend/tests/tests_core/test_api_hoods.py index 33421d6..3fca51c 100644 --- a/backend/tests/tests_core/test_api_hoods.py +++ b/backend/tests/tests_core/test_api_hoods.py @@ -3,80 +3,107 @@ # Copyright (C) 2020 by Martin Rey # # SPDX-License-Identifier: 0BSD - +import pytest from fastapi import status -def test_hood_read_all(client): - response = client.get("/api/hoods/") +@pytest.mark.anyio +async def test_hood_read_all(asyncclient): + response = await asyncclient.get("/api/hoods/") assert response.status_code == status.HTTP_200_OK -def test_hood_create_unauthorized(client, hood_id): - response = client.post("/api/hoods/") +@pytest.mark.anyio +async def test_hood_create_unauthorized(asyncclient, hood_id): + response = await asyncclient.post("/api/hoods/") assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_hood_read(client, hood_id): - response = client.get("/api/hoods/{0}".format(hood_id)) +@pytest.mark.anyio +async def test_hood_read(asyncclient, hood_id): + response = await asyncclient.get("/api/hoods/{0}".format(hood_id)) assert response.status_code == status.HTTP_200_OK -def test_hood_update_unauthorized(client, hood_id): - response = client.put("/api/hoods/{0}".format(hood_id)) +@pytest.mark.anyio +async def test_hood_update_unauthorized(asyncclient, hood_id): + response = await asyncclient.put("/api/hoods/{0}".format(hood_id)) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_hood_delete_unauthorized(client, hood_id): - response = client.delete("/api/hoods/{0}".format(hood_id)) +@pytest.mark.anyio +async def test_hood_delete_unauthorized(asyncclient, hood_id): + response = await asyncclient.delete("/api/hoods/{0}".format(hood_id)) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_trigger_read_all_unauthorized(client, hood_id): - response = client.get("/api/hoods/{0}/triggers/".format(hood_id)) +@pytest.mark.anyio +async def test_trigger_read_all_unauthorized(asyncclient, hood_id): + response = await asyncclient.get("/api/hoods/{0}/triggers/".format(hood_id)) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_trigger_create_unauthorized(client, hood_id): - response = client.post("/api/hoods/{0}/triggers/".format(hood_id)) +@pytest.mark.anyio +async def test_trigger_create_unauthorized(asyncclient, hood_id): + response = await asyncclient.post("/api/hoods/{0}/triggers/".format(hood_id)) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_trigger_read_unauthorized(client, hood_id, trigger_id): - response = client.get("/api/hoods/{0}/triggers/{1}".format(hood_id, trigger_id)) +@pytest.mark.anyio +async def test_trigger_read_unauthorized(asyncclient, hood_id, trigger_id): + response = await asyncclient.get( + "/api/hoods/{0}/triggers/{1}".format(hood_id, trigger_id) + ) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_trigger_update_unauthorized(client, hood_id, trigger_id): - response = client.put("/api/hoods/{0}/triggers/{1}".format(hood_id, trigger_id)) +@pytest.mark.anyio +async def test_trigger_update_unauthorized(asyncclient, hood_id, trigger_id): + response = await asyncclient.put( + "/api/hoods/{0}/triggers/{1}".format(hood_id, trigger_id) + ) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_trigger_delete_unauthorized(client, hood_id, trigger_id): - response = client.delete("/api/hoods/{0}/triggers/{1}".format(hood_id, trigger_id)) +@pytest.mark.anyio +async def test_trigger_delete_unauthorized(asyncclient, hood_id, trigger_id): + response = await asyncclient.delete( + "/api/hoods/{0}/triggers/{1}".format(hood_id, trigger_id) + ) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_badword_read_all_unauthorized(client, hood_id): - response = client.get("/api/hoods/{0}/badwords/".format(hood_id)) +@pytest.mark.anyio +async def test_badword_read_all_unauthorized(asyncclient, hood_id): + response = await asyncclient.get("/api/hoods/{0}/badwords/".format(hood_id)) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_badword_create_unauthorized(client, hood_id): - response = client.post("/api/hoods/{0}/badwords/".format(hood_id)) +@pytest.mark.anyio +async def test_badword_create_unauthorized(asyncclient, hood_id): + response = await asyncclient.post("/api/hoods/{0}/badwords/".format(hood_id)) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_badword_read_unauthorized(client, hood_id, badword_id): - response = client.get("/api/hoods/{0}/badwords/{1}".format(hood_id, badword_id)) +@pytest.mark.anyio +async def test_badword_read_unauthorized(asyncclient, hood_id, badword_id): + response = await asyncclient.get( + "/api/hoods/{0}/badwords/{1}".format(hood_id, badword_id) + ) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_badword_update_unauthorized(client, hood_id, badword_id): - response = client.put("/api/hoods/{0}/badwords/{1}".format(hood_id, badword_id)) +@pytest.mark.anyio +async def test_badword_update_unauthorized(asyncclient, hood_id, badword_id): + response = await asyncclient.put( + "/api/hoods/{0}/badwords/{1}".format(hood_id, badword_id) + ) assert response.status_code == status.HTTP_401_UNAUTHORIZED -def test_badword_delete_unauthorized(client, hood_id, badword_id): - response = client.delete("/api/hoods/{0}/badwords/{1}".format(hood_id, badword_id)) +@pytest.mark.anyio +async def test_badword_delete_unauthorized(asyncclient, hood_id, badword_id): + response = await asyncclient.delete( + "/api/hoods/{0}/badwords/{1}".format(hood_id, badword_id) + ) assert response.status_code == status.HTTP_401_UNAUTHORIZED