"""Render the real asset workspace for browser validation; no DB or user data.""" import json import sys from pathlib import Path import jinja2 ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT)) sys.path.insert(0, str(ROOT / "tests")) from app.modules.asset.store import CATEGORIES, STATUSES from app.modules.asset.hwinfo import parse_hwinfo from asset_fixtures import report_xml env = jinja2.Environment(loader=jinja2.ChoiceLoader([ jinja2.FileSystemLoader(ROOT / "app/modules/asset/templates"), jinja2.FileSystemLoader(ROOT / "app/templates"), ]), autoescape=True) out = ROOT / "tests/js/.out" out.mkdir(exist_ok=True, parents=True) for configured in (True, False): html = env.get_template("asset/index.html").render( user={"email": "reader@test.local", "name": "Reader"}, nav_items=[], is_admin=False, page_title="자산관리", page_subtitle="회사 자산을 한곳에서", categories=CATEGORIES, statuses=STATUSES, csrf_token="browser-test", configured=configured) (out / ("asset_render.html" if configured else "asset_unconfigured.html")).write_text(html, encoding="utf-8") sample = ROOT / "KING-DESKTOP.XML" raw = sample.read_bytes() if sample.exists() else report_xml() (out / "asset_report.json").write_text(json.dumps(parse_hwinfo(raw), ensure_ascii=False), encoding="utf-8") # Synthetic file for upload tests, never copy the private source XML into artifacts. (out / "asset_upload.xml").write_bytes(report_xml()) print("Asset template and report analysis rendered to tests/js/.out")