--
This commit is contained in:
@@ -37,6 +37,7 @@ from app.users.models import User # noqa: E402
|
||||
TABLES = [
|
||||
"audit_log",
|
||||
"product",
|
||||
"missed_visit",
|
||||
"doctor_call",
|
||||
"chemist_call",
|
||||
"daily_call_report",
|
||||
@@ -169,6 +170,34 @@ async def org(db: AsyncSession) -> dict:
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def approved_plan(db: AsyncSession, org: dict):
|
||||
"""An empty day plan, already approved, so an end-of-day report may be filed.
|
||||
|
||||
For tests about end-of-day rules where the plan is incidental; the plan flow itself
|
||||
is exercised through the API in tests/e2e/test_day_plan.py.
|
||||
"""
|
||||
from app.common.enums import DCRStatus, ReportType
|
||||
from app.common.utils import utcnow
|
||||
from app.reports.models import DailyCallReport
|
||||
|
||||
async def make(day: date | None = None, mr: str = "mr1") -> DailyCallReport:
|
||||
plan = DailyCallReport(
|
||||
id=uuid.uuid4(),
|
||||
mr_user_id=org[mr].id,
|
||||
headquarters_id=org[mr].headquarters_id,
|
||||
report_date=day or date.today(),
|
||||
report_type=ReportType.PLAN,
|
||||
status=DCRStatus.APPROVED,
|
||||
approved_at=utcnow(),
|
||||
)
|
||||
db.add(plan)
|
||||
await db.commit()
|
||||
return plan
|
||||
|
||||
return make
|
||||
|
||||
|
||||
async def login(client: AsyncClient, user: User) -> dict[str, str]:
|
||||
resp = await client.post(
|
||||
"/api/v1/auth/login",
|
||||
|
||||
Reference in New Issue
Block a user