fix: Lint fixes of last tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Tests for authentication service."""
|
||||
# ruff: noqa: S106, SLF001, PLC0415
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
@@ -10,6 +11,11 @@ from app.models.user import User
|
||||
from app.schemas.auth import UserLoginRequest, UserRegisterRequest
|
||||
from app.services.auth import AuthService
|
||||
|
||||
# Constants
|
||||
HTTP_400_BAD_REQUEST = 400
|
||||
HTTP_401_UNAUTHORIZED = 401
|
||||
HTTP_404_NOT_FOUND = 404
|
||||
|
||||
|
||||
class TestAuthService:
|
||||
"""Test authentication service operations."""
|
||||
@@ -62,7 +68,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.register(request)
|
||||
|
||||
assert exc_info.value.status_code == 400
|
||||
assert exc_info.value.status_code == HTTP_400_BAD_REQUEST
|
||||
assert "Email address is already registered" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -100,7 +106,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.login(request)
|
||||
|
||||
assert exc_info.value.status_code == 401
|
||||
assert exc_info.value.status_code == HTTP_401_UNAUTHORIZED
|
||||
assert "Invalid email or password" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -115,7 +121,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.login(request)
|
||||
|
||||
assert exc_info.value.status_code == 401
|
||||
assert exc_info.value.status_code == HTTP_401_UNAUTHORIZED
|
||||
assert "Invalid email or password" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -138,7 +144,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.login(request)
|
||||
|
||||
assert exc_info.value.status_code == 401
|
||||
assert exc_info.value.status_code == HTTP_401_UNAUTHORIZED
|
||||
assert "Account is deactivated" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -161,7 +167,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.login(request)
|
||||
|
||||
assert exc_info.value.status_code == 401
|
||||
assert exc_info.value.status_code == HTTP_401_UNAUTHORIZED
|
||||
assert "Invalid email or password" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -184,7 +190,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.get_current_user(99999)
|
||||
|
||||
assert exc_info.value.status_code == 404
|
||||
assert exc_info.value.status_code == HTTP_404_NOT_FOUND
|
||||
assert "User not found" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -205,7 +211,7 @@ class TestAuthService:
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
await auth_service.get_current_user(user_id)
|
||||
|
||||
assert exc_info.value.status_code == 401
|
||||
assert exc_info.value.status_code == HTTP_401_UNAUTHORIZED
|
||||
assert "Account is deactivated" in exc_info.value.detail
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user