test: update integration tests for RESTful routes
This commit is contained in:
@@ -4,51 +4,53 @@ import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from v1.auth.schemas import (
|
||||
AuthTokenResponse,
|
||||
AuthUser,
|
||||
LoginRequest,
|
||||
RefreshRequest,
|
||||
SignupStartRequest,
|
||||
SignupVerifyRequest,
|
||||
SignupResendRequest,
|
||||
SessionCreateRequest,
|
||||
SessionRefreshRequest,
|
||||
SessionResponse,
|
||||
VerificationCreateRequest,
|
||||
VerificationVerifyRequest,
|
||||
VerificationResendRequest,
|
||||
)
|
||||
|
||||
|
||||
def test_signup_requires_valid_email() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
SignupStartRequest(username="demo", email="not-an-email", password="secret123")
|
||||
VerificationCreateRequest(
|
||||
username="demo", email="not-an-email", password="secret123"
|
||||
)
|
||||
|
||||
|
||||
def test_signup_requires_username() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
SignupStartRequest.model_validate(
|
||||
VerificationCreateRequest.model_validate(
|
||||
{"email": "user@example.com", "password": "secret123"}
|
||||
)
|
||||
|
||||
|
||||
def test_signup_verify_requires_six_digit_token() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
SignupVerifyRequest(email="user@example.com", token="abc123")
|
||||
VerificationVerifyRequest(email="user@example.com", token="abc123")
|
||||
|
||||
|
||||
def test_signup_resend_requires_valid_email() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
SignupResendRequest(email="invalid")
|
||||
VerificationResendRequest(email="invalid")
|
||||
|
||||
|
||||
def test_login_requires_valid_email() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
LoginRequest(email="invalid", password="secret123")
|
||||
SessionCreateRequest(email="invalid", password="secret123")
|
||||
|
||||
|
||||
def test_refresh_requires_token() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
RefreshRequest(refresh_token="")
|
||||
SessionRefreshRequest(refresh_token="")
|
||||
|
||||
|
||||
def test_auth_token_response_maps_user() -> None:
|
||||
def test_session_response_maps_user() -> None:
|
||||
user = AuthUser(id="user-1", email="user@example.com")
|
||||
response = AuthTokenResponse(
|
||||
response = SessionResponse(
|
||||
access_token="access",
|
||||
refresh_token="refresh",
|
||||
expires_in=3600,
|
||||
|
||||
Reference in New Issue
Block a user