Milestone 288 — pattern library + forge integration #111
@@ -88,10 +88,21 @@ async def _dispose_engine():
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def user_id(_dispose_engine):
|
||||
# Get-or-create: the lane's database persists across tests, so a second
|
||||
# test re-creating the same username dies on the unique constraint.
|
||||
from sqlalchemy import select
|
||||
|
||||
from scribe.models import async_session
|
||||
from scribe.models.user import User
|
||||
|
||||
async with async_session() as s:
|
||||
existing = (
|
||||
await s.execute(
|
||||
select(User).where(User.username == "snippet_prov_itest")
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
if existing is not None:
|
||||
return existing.id
|
||||
user = User(username="snippet_prov_itest")
|
||||
s.add(user)
|
||||
await s.flush()
|
||||
|
||||
Reference in New Issue
Block a user