Fix(backend): Updated authenticated Ctxmanager
- After Quart update, we can't test if an user is authenticated anymore with only `quart` but we also have to rely on `quart_auth.authenticated_client`. All tests passed after changes were made.
This commit is contained in:
parent
62daa16646
commit
979e504c0d
@ -2,6 +2,7 @@ import pytest
|
|||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
from itsdangerous import URLSafeTimedSerializer
|
from itsdangerous import URLSafeTimedSerializer
|
||||||
from quart import Quart
|
from quart import Quart
|
||||||
|
from quart_auth import authenticated_client
|
||||||
|
|
||||||
from backend.blueprints.members import EMAIL_VERIFICATION_SALT
|
from backend.blueprints.members import EMAIL_VERIFICATION_SALT
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ async def test_change_password(app: Quart, caplog: pytest.LogCaptureFixture) ->
|
|||||||
"password": "testPassword2$",
|
"password": "testPassword2$",
|
||||||
}
|
}
|
||||||
response = await test_client.post("/members/", json=data)
|
response = await test_client.post("/members/", json=data)
|
||||||
async with test_client.authenticated("2"): # type: ignore
|
async with authenticated_client(test_client, auth_id=2): # type: ignore
|
||||||
response = await test_client.put(
|
response = await test_client.put(
|
||||||
"/members/password/",
|
"/members/password/",
|
||||||
json={
|
json={
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from quart import Quart
|
from quart import Quart
|
||||||
|
from quart_auth import authenticated_client
|
||||||
|
|
||||||
|
|
||||||
async def test_post_todo(app: Quart) -> None:
|
async def test_post_todo(app: Quart) -> None:
|
||||||
test_client = app.test_client()
|
test_client = app.test_client()
|
||||||
async with test_client.authenticated("1"): # type: ignore
|
async with authenticated_client(test_client, auth_id=1): # type: ignore
|
||||||
response = await test_client.post(
|
response = await test_client.post(
|
||||||
"/todos/",
|
"/todos/",
|
||||||
json={"complete": False, "due": None, "task": "Test task"},
|
json={"complete": False, "due": None, "task": "Test task"},
|
||||||
@ -14,7 +15,7 @@ async def test_post_todo(app: Quart) -> None:
|
|||||||
|
|
||||||
async def test_get_todo(app: Quart) -> None:
|
async def test_get_todo(app: Quart) -> None:
|
||||||
test_client = app.test_client()
|
test_client = app.test_client()
|
||||||
async with test_client.authenticated("1"): # type: ignore
|
async with authenticated_client(test_client, auth_id=1): # type: ignore
|
||||||
response = await test_client.get("/todos/1/")
|
response = await test_client.get("/todos/1/")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert (await response.get_json())["task"] == "Test Task"
|
assert (await response.get_json())["task"] == "Test Task"
|
||||||
@ -22,7 +23,7 @@ async def test_get_todo(app: Quart) -> None:
|
|||||||
|
|
||||||
async def test_put_todo(app: Quart) -> None:
|
async def test_put_todo(app: Quart) -> None:
|
||||||
test_client = app.test_client()
|
test_client = app.test_client()
|
||||||
async with test_client.authenticated("1"): # type: ignore
|
async with authenticated_client(test_client, auth_id=1): # type: ignore
|
||||||
response = await test_client.post(
|
response = await test_client.post(
|
||||||
"/todos/",
|
"/todos/",
|
||||||
json={"complete": False, "due": None, "task": "Test task"},
|
json={"complete": False, "due": None, "task": "Test task"},
|
||||||
@ -41,7 +42,7 @@ async def test_put_todo(app: Quart) -> None:
|
|||||||
|
|
||||||
async def test_delete_todo(app: Quart) -> None:
|
async def test_delete_todo(app: Quart) -> None:
|
||||||
test_client = app.test_client()
|
test_client = app.test_client()
|
||||||
async with test_client.authenticated("1"): # type: ignore
|
async with authenticated_client(test_client, auth_id=1): # type: ignore
|
||||||
response = await test_client.post(
|
response = await test_client.post(
|
||||||
"/todos/",
|
"/todos/",
|
||||||
json={"complete": False, "due": None, "task": "Test task"},
|
json={"complete": False, "due": None, "task": "Test task"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user