Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
33 lines
922 B
Python
33 lines
922 B
Python
import pytest
|
|
from rest_framework.test import APIClient
|
|
|
|
|
|
@pytest.fixture
|
|
def api():
|
|
return APIClient()
|
|
|
|
|
|
@pytest.fixture
|
|
def user(db):
|
|
from apps.accounts.models import User
|
|
|
|
return User.objects.create_user(
|
|
username="u@x.com", email="u@x.com", password="pw1234", user_name="유저"
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def auth_api(api, user):
|
|
"""로그인된 클라이언트 + 토큰 응답."""
|
|
res = api.post("/api/v1/auth/login", {"email": "u@x.com", "password": "pw1234"}, format="json")
|
|
tokens = res.json()["data"]
|
|
api.credentials(HTTP_AUTHORIZATION=f"Bearer {tokens['token']}")
|
|
api.tokens = tokens
|
|
return api
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _no_langfuse(settings):
|
|
"""테스트가 로컬 .env 의 LANGFUSE_HOST 로 진짜 전송하는 사고 방지. 보내는 테스트는 override_settings 로 켬."""
|
|
settings.LANGFUSE = {"host": "", "public_key": "", "secret_key": ""}
|