Feat(API + Docs): Handle user sessions

- Improved documentation
- Wrote tests for user sessions/authentications: including session
  flow(login, status, logout)
This commit is contained in:
minhtrannhat
2022-12-24 22:01:23 -05:00
parent 8a695f2efb
commit f129c6884e
5 changed files with 123 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
from quart import Quart
async def test_session_flow(app: Quart) -> None:
test_client = app.test_client()
await test_client.post(
"/sessions/",
json={"email": "member@todo.minhtrannhat.com", "password": "password"},
)
response = await test_client.get("/sessions/")
assert (await response.get_json())["memberId"] == 1
await test_client.delete("/sessions/")
response = await test_client.get("/sessions/")
assert response.status_code == 401
async def test_login_invalid_password(app: Quart) -> None:
test_client = app.test_client()
await test_client.post(
"/sessions/",
json={"email": "member@todo.minhtrannhat.com", "password": "incorrect"},
)
response = await test_client.get("/sessions/")
assert response.status_code == 401