from __future__ import annotations
from typing import TYPE_CHECKING, Any
import pytest
import respx
from authframework import AuthFrameworkClient
if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Generator
@pytest.fixture
def base_url() -> str:
return "https://api.authframework.test"
@pytest.fixture
def api_key() -> str:
return "test-api-key-12345"
@pytest.fixture
async def client(
base_url: str,
api_key: str,
) -> AsyncGenerator[AuthFrameworkClient, None]:
async with AuthFrameworkClient(
base_url=base_url,
api_key=api_key,
timeout=5.0,
retries=1,
) as client:
yield client
@pytest.fixture
def mock_responses() -> Generator[Any, None, None]:
with respx.mock:
yield respx
@pytest.fixture
def sample_user_data() -> dict[str, Any]:
return {
"id": "user123",
"username": "testuser",
"email": "test@example.com",
"first_name": "Test",
"last_name": "User",
"is_active": True,
"created_at": "2024-01-01T00:00:00Z",
}
@pytest.fixture
def sample_login_response() -> dict[str, Any]:
return {
"access_token": "test-access-token",
"refresh_token": "test-refresh-token",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "user123",
"username": "testuser",
"email": "test@example.com",
},
}
@pytest.fixture
def sample_error_response() -> dict[str, Any]:
return {
"error": {
"code": "INVALID_CREDENTIALS",
"message": "Invalid username or password",
"details": {"field": "password"},
},
}