More refactoring
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import pytest
|
||||
|
||||
from tests.base import avatar_index, client, password, register_user, username
|
||||
from tests.base import (avatar_index, client, get_headers, password,
|
||||
register_user, username)
|
||||
from tests.config.database import clear_db
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_register():
|
||||
async def test_register_should_succeed():
|
||||
"""Test the register endpoint"""
|
||||
clear_db()
|
||||
|
||||
response = client.post(
|
||||
"/register",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username, "password": password, "avatar_index": avatar_index},
|
||||
)
|
||||
|
||||
@@ -27,7 +28,7 @@ async def test_register_duplicate_name_should_fail():
|
||||
|
||||
response = client.post(
|
||||
"/register",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username, "password": password, "avatar_index": avatar_index},
|
||||
)
|
||||
|
||||
@@ -42,7 +43,7 @@ async def test_register_without_username_should_fail():
|
||||
|
||||
response = client.post(
|
||||
"/register",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"password": password, "avatar_index": avatar_index},
|
||||
)
|
||||
|
||||
@@ -57,7 +58,7 @@ async def test_register_without_password_should_fail():
|
||||
|
||||
response = client.post(
|
||||
"/register",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username, "avatar_index": avatar_index},
|
||||
)
|
||||
|
||||
@@ -72,7 +73,7 @@ async def test_register_without_avatar_should_fail():
|
||||
|
||||
response = client.post(
|
||||
"/register",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username, "password": password},
|
||||
)
|
||||
|
||||
@@ -81,14 +82,14 @@ async def test_register_without_avatar_should_fail():
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_login():
|
||||
async def test_login_should_succeed():
|
||||
"""Test the login endpoint"""
|
||||
clear_db()
|
||||
await register_user()
|
||||
|
||||
response = client.post(
|
||||
"/login",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username, "password": password},
|
||||
)
|
||||
|
||||
@@ -104,7 +105,7 @@ async def test_login_wrong_password_should_fail():
|
||||
wrong_password = password + "extra characters"
|
||||
response = client.post(
|
||||
"/login",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username, "password": wrong_password},
|
||||
)
|
||||
|
||||
@@ -120,7 +121,7 @@ async def test_login_without_username_should_fail():
|
||||
|
||||
response = client.post(
|
||||
"/login",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"password": password},
|
||||
)
|
||||
|
||||
@@ -136,7 +137,7 @@ async def test_login_without_password_should_fail():
|
||||
|
||||
response = client.post(
|
||||
"/login",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": username},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user