Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web_strategy_studio/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ studio_api = ["data/*.json"]
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
asyncio_mode = "auto"

[tool.ruff]
line-length = 100
Expand Down
16 changes: 7 additions & 9 deletions web_strategy_studio/backend/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TestAuthEndpoints:
"""Test the /auth endpoints using httpx + FastAPI TestClient."""

@pytest.fixture
def client(self, tmp_path):
async def client(self, tmp_path):
"""Create a test client with a fresh SQLite DB in tmp_path."""
from httpx import ASGITransport, AsyncClient

Expand All @@ -84,18 +84,16 @@ def client(self, tmp_path):
new_engine, class_=db_mod.AsyncSession, expire_on_commit=False
)

import asyncio

async def setup_db():
async with new_engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)

asyncio.get_event_loop().run_until_complete(setup_db())
async with new_engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)

from studio_api.app import app

transport = ASGITransport(app=app)
return AsyncClient(transport=transport, base_url="http://test")
async with AsyncClient(transport=transport, base_url="http://test") as ac:
yield ac

await new_engine.dispose()

@pytest.mark.asyncio
async def test_register_returns_token(self, client):
Expand Down