"""看板工作汇报页:单页 HTML 同时覆盖日常工作、自研产品、定制项目与年度财务表。""" from __future__ import annotations from app import constants from app.db import SessionLocal from app.models import CustomProject def test_看板导出完整工作汇报页(h): week = h.period(2028, 3, 2) old_week = h.period(2028, 2, 1) first = constants.period_first_day(2028, 3, 2) project = h.project("自研甲", owners=["王芳"], is_key=True) second_project = h.project("自研乙", owners=["李四"], is_key=True) h.update(project["id"], week["id"], content="完成联调", summary='
整理验收清单完成
第二行
', due_date="2028-03-20") h.focus("历史遗留任务", period_id=old_week["id"], detail="不该出现在选中周期", delayed=True) added = h.custom("新增乙", origin="华智下单", amount=100000, sign_date=first, update_date=first, project_status="进行中") accepted = h.custom("验收丙", origin="华智下单", amount=200000, update_date=first, project_status="已验收") risky = h.custom("高风险丁", origin="华智下单", amount=300000, risk_level="1.高风险") idle_risky = h.custom("高风险戊", origin="华智下单", amount=400000, risk_level="1.高风险") h.custom_update(risky["id"], week["id"], content="协调风险") # 创建接口固定写今天;把周期字段改成选中周期,对齐看板的「本期」口径 with SessionLocal() as db: for name in ("新增乙", "验收丙"): row = next(row for row in db.query(CustomProject).all() if row.name == name) row.update_date = first + " 09:00" row.sign_date = first db.commit() resp = h.admin.get("/api/export/board-report", params={"period_id": week["id"]}) assert resp.status_code == 200, resp.text assert resp.headers["content-type"].startswith("text/html") assert "attachment" in resp.headers["content-disposition"] assert ".html" in resp.headers["content-disposition"] body = resp.text range_label = week["full_label"] assert f"