More refactoring
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from tests.base import avatar_index, client, register_user, username
|
||||
from tests.base import (avatar_index, client, get_headers, register_user,
|
||||
username)
|
||||
from tests.config.database import clear_db
|
||||
|
||||
patched_username = "New name"
|
||||
@@ -9,13 +10,13 @@ patched_avatar_index = 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_user():
|
||||
async def test_patch_user_should_succeed():
|
||||
"""Test the patching of a user's username, password and avatar"""
|
||||
clear_db()
|
||||
|
||||
token = await register_user()
|
||||
|
||||
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
|
||||
headers = get_headers(token)
|
||||
|
||||
response = client.patch(
|
||||
"/users",
|
||||
@@ -30,14 +31,14 @@ async def test_patch_user():
|
||||
|
||||
response = client.post(
|
||||
"/login",
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers=get_headers(),
|
||||
json={"username": patched_username, "password": patched_password},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
token = response.json()["access_token"]
|
||||
|
||||
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
|
||||
headers = get_headers(token)
|
||||
|
||||
response = client.get("/saveddata", headers=headers)
|
||||
assert response.status_code == 200
|
||||
@@ -47,13 +48,13 @@ async def test_patch_user():
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_user_with_empty_fields():
|
||||
"""Patching a user with empty fields should fail"""
|
||||
async def test_patch_user_with_empty_fields_should_succeed():
|
||||
"""Patching a user with empty fields should still succeed"""
|
||||
clear_db()
|
||||
|
||||
token = await register_user()
|
||||
|
||||
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
|
||||
headers = get_headers(token)
|
||||
|
||||
response = client.patch(
|
||||
"/users",
|
||||
|
||||
Reference in New Issue
Block a user