# tests/smoke_v2.py """Lightweight smoke tests for V2 modules and schema shape.""" from pathlib import Path from src import config, billing, modal_templates, styles, store from src.paths import cases_dir, exports_dir def test_paths_exist(): pd = config.paths_dict() assert "cases_dir" in pd and "exports_dir" in pd cases_dir().mkdir(parents=True, exist_ok=True) exports_dir().mkdir(parents=True, exist_ok=True) def test_seed_cases_and_schema(): created = store.seed_cases(reset=True) assert len(created) == 4 for cid in created: case = store.read_case(cid) assert case is not None for k in ["schema_version", "status", "created_at", "updated_at", "billing", "explainability"]: assert k in case, f"missing {k} in {cid}" assert case["schema_version"] == config.SCHEMA_VERSION assert isinstance(case["explainability"].get("manually_modified"), bool) def test_billing_autosuggest(): s1 = billing.autosuggest_cpt(minutes=5, spoke=False) codes1 = [s.code for s in s1] assert "99451" in codes1 assert any(s.eligible for s in s1), "99451 should be eligible at 5 min (written report)" s2 = billing.autosuggest_cpt(minutes=12, spoke=True) codes2 = [s.code for s in s2] assert "99446" in codes2 and "99447" in codes2, "Discussed pathway should list 99446/99447 etc." assert any(s.code == "99447" and s.eligible for s in s2), "12 min should make 99447 eligible" def test_837_builder(): created = store.seed_cases(reset=True) case = store.read_case(created[0]) assert case is not None sug = billing.autosuggest_cpt(minutes=12, spoke=True) pick = next(s for s in sug if s.code == "99447") claim = billing.build_837_claim(case, pick.code, pick.rate, 12, True, attested=True) assert claim["service"]["cpt_code"] == "99447" assert claim["attested"] is True def test_export_filename_builder(): p = config.make_export_path("TEST123", "consult_note.md") assert p.name.startswith("EC-TEST123_") and p.name.endswith("_consult_note.md") def test_modal_templates_importable(): # Ensure callables exist; we don't render in tests assert hasattr(modal_templates, "show_consult_note_preview") assert hasattr(modal_templates, "show_837_claim_preview")