Coverage for tests\test_login.py: 100%
17 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-05 19:00 +0800
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-05 19:00 +0800
1import httpx
2import pytest
5@pytest.mark.asyncio
6async def test_sign_new_user(default_client: httpx.AsyncClient) -> None:
7 payload = {
8 "email": "testuser@packt.com",
9 "password": "testpassword",
10 }
12 headers = {
13 "accept": "application/json",
14 "Content-Type": "application/json"
15 }
17 test_response = {
18 "message": "User created successfully"
19 }
21 response = await default_client.post("/user/signup", json=payload, headers=headers)
23 assert response.status_code == 200
24 assert response.json() == test_response
27@pytest.mark.asyncio
28async def test_sign_user_in(default_client: httpx.AsyncClient) -> None:
29 payload = {
30 "username": "testuser@packt.com",
31 "password": "testpassword"
32 }
34 headers = {
35 "accept": "application/json",
36 "Content-Type": "application/x-www-form-urlencoded"
37 }
39 response = await default_client.post("/user/signin", data=payload, headers=headers)
41 assert response.status_code == 200
42 assert response.json()["token_type"] == "Bearer"