fix(faq): persist active defaults for medical consults
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import text
|
||||
import pytest
|
||||
|
||||
from app.crud.faq_category import create_category
|
||||
from app.crud.faq_item import create_item
|
||||
from app.schemas.faq import CategoryCreate, FaqCreate
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_category_defaults_to_active(db_session):
|
||||
result = await db_session.execute(text("SELECT id FROM studies LIMIT 1"))
|
||||
study_id = result.scalar_one()
|
||||
|
||||
category = await create_category(
|
||||
db_session,
|
||||
CategoryCreate(study_id=study_id, name="AE", sort_order=0),
|
||||
)
|
||||
|
||||
assert category.is_active is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_item_defaults_to_active(db_session):
|
||||
result = await db_session.execute(text("SELECT id FROM studies LIMIT 1"))
|
||||
study_id = result.scalar_one()
|
||||
category = await create_category(
|
||||
db_session,
|
||||
CategoryCreate(study_id=study_id, name=f"AE-{uuid.uuid4().hex[:8]}", sort_order=0),
|
||||
)
|
||||
|
||||
item = await create_item(
|
||||
db_session,
|
||||
FaqCreate(study_id=study_id, category_id=category.id, question="AE 如何记录?"),
|
||||
created_by=uuid.uuid4(),
|
||||
)
|
||||
|
||||
assert item.is_active is True
|
||||
Reference in New Issue
Block a user