mirror of
http://88.130.71.182:3000/BlitTech/deals24togo_be.git
synced 2026-06-12 23:33:21 +00:00
Initial commit
This commit is contained in:
40
tests/conftest.py
Normal file
40
tests/conftest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Test fixtures and configuration."""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
# Set test env vars before importing app
|
||||
os.environ.setdefault("SUPABASE_URL", "https://test.supabase.co")
|
||||
os.environ.setdefault("SUPABASE_KEY", "test-key")
|
||||
os.environ.setdefault("SUPABASE_SERVICE_ROLE_KEY", "test-service-key")
|
||||
os.environ.setdefault("SUPABASE_JWT_SECRET", "test-jwt-secret")
|
||||
os.environ.setdefault("APP_ENV", "test")
|
||||
os.environ.setdefault("DEBUG", "true")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
from app.main import create_app
|
||||
return create_app()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
return TestClient(app)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def auth_headers():
|
||||
"""Generate auth headers with a Supabase-format test JWT."""
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from jose import jwt
|
||||
|
||||
payload = {
|
||||
"sub": "test-user-id",
|
||||
"aud": "authenticated",
|
||||
"role": "visitor",
|
||||
"exp": datetime.now(timezone.utc) + timedelta(hours=1),
|
||||
}
|
||||
token = jwt.encode(payload, "test-jwt-secret", algorithm="HS256")
|
||||
return {"Authorization": f"Bearer {token}"}
|
||||
Reference in New Issue
Block a user