pytest 1.7

This commit is contained in:
2025-10-12 18:59:42 +03:00
parent c015a25c81
commit 903cb7c930
2 changed files with 25 additions and 2 deletions

View File

@@ -77,12 +77,35 @@ async def test_is_admin(client, monkeypatch, global_email, is_admin, expected_st
assert response.status_code == expected_status
api.dependency_overrides.clear()
@pytest.mark.asyncio
@pytest.mark.parametrize("email,password,expected_status", [
("valid", "123qwe!@#", 200),
("invalidemail.com", "123qwe!@#", 422),
("invalidpassword", "1234", 422),
("invalidall", "1234", 422)
])
async def test_login_user(client, email, password, expected_status, global_email):
'''Проверка: Логин пользователя'''
if email == "valid":
email = global_email #Подставка глобальной фикстуры под конкретный вариант
user_data = {
"username": email,
"password": password
}
response = await client.post(f"/login", data=user_data)
assert response.status_code == expected_status
@pytest.mark.parametrize("is_admin, can_delete,expected_status", [
(False,True,200),
(True,True,200),
(True,False,200),
(False, False,403)
])
@pytest.mark.asyncio
async def test_delete_user(client, global_email, monkeypatch, is_admin, expected_status, can_delete):
"""Проверка: Удаление пользователя"""