106 lines
3.2 KiB
Python
106 lines
3.2 KiB
Python
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
from scripts.plan_nh_broadband_install import (
|
|
build_packet,
|
|
load_request,
|
|
render_markdown,
|
|
validate_request,
|
|
)
|
|
|
|
|
|
def test_script_exists() -> None:
|
|
assert Path("scripts/plan_nh_broadband_install.py").exists()
|
|
|
|
|
|
def test_example_request_exists() -> None:
|
|
assert Path("docs/nh-broadband-install-request.example.yaml").exists()
|
|
|
|
|
|
def test_example_packet_exists() -> None:
|
|
assert Path("docs/nh-broadband-install-packet.example.md").exists()
|
|
|
|
|
|
def test_research_memo_exists() -> None:
|
|
assert Path("reports/operations/2026-04-15-nh-broadband-public-research.md").exists()
|
|
|
|
|
|
def test_load_and_build_packet() -> None:
|
|
data = load_request("docs/nh-broadband-install-request.example.yaml")
|
|
packet = build_packet(data)
|
|
assert packet["contact"]["name"] == "Timmy Operator"
|
|
assert packet["service_address"]["city"] == "Concord"
|
|
assert packet["service_address"]["state"] == "NH"
|
|
assert packet["status"] == "pending_scheduling_call"
|
|
assert len(packet["checklist"]) == 8
|
|
assert packet["checklist"][0]["done"] is False
|
|
|
|
|
|
def test_validate_rejects_missing_contact_name() -> None:
|
|
data = {
|
|
"contact": {"name": "", "phone": "555"},
|
|
"service": {"address": "1 St", "city": "X", "state": "NH"},
|
|
"checklist": ["do thing"],
|
|
}
|
|
try:
|
|
validate_request(data)
|
|
except ValueError as exc:
|
|
assert "contact.name" in str(exc)
|
|
else:
|
|
raise AssertionError("should reject empty contact name")
|
|
|
|
|
|
def test_validate_rejects_missing_service_address() -> None:
|
|
data = {
|
|
"contact": {"name": "A", "phone": "555"},
|
|
"service": {"address": "", "city": "X", "state": "NH"},
|
|
"checklist": ["do thing"],
|
|
}
|
|
try:
|
|
validate_request(data)
|
|
except ValueError as exc:
|
|
assert "service.address" in str(exc)
|
|
else:
|
|
raise AssertionError("should reject empty service address")
|
|
|
|
|
|
def test_validate_rejects_empty_checklist() -> None:
|
|
data = {
|
|
"contact": {"name": "A", "phone": "555"},
|
|
"service": {"address": "1 St", "city": "X", "state": "NH"},
|
|
"checklist": [],
|
|
}
|
|
try:
|
|
validate_request(data)
|
|
except ValueError as exc:
|
|
assert "checklist" in str(exc)
|
|
else:
|
|
raise AssertionError("should reject empty checklist")
|
|
|
|
|
|
def test_render_markdown_contains_key_sections() -> None:
|
|
data = load_request("docs/nh-broadband-install-request.example.yaml")
|
|
packet = build_packet(data)
|
|
md = render_markdown(packet, data)
|
|
assert "# NH Broadband Install Packet" in md
|
|
assert "## Contact" in md
|
|
assert "## Service Address" in md
|
|
assert "## Call Log" in md
|
|
assert "## Appointment Checklist" in md
|
|
assert "Concord" in md
|
|
assert "NH" in md
|
|
|
|
|
|
def test_render_markdown_shows_checklist_items() -> None:
|
|
data = load_request("docs/nh-broadband-install-request.example.yaml")
|
|
packet = build_packet(data)
|
|
md = render_markdown(packet, data)
|
|
assert "- [ ] Confirm exact-address availability" in md
|
|
|
|
|
|
def test_example_yaml_is_valid() -> None:
|
|
data = yaml.safe_load(Path("docs/nh-broadband-install-request.example.yaml").read_text())
|
|
assert data["contact"]["name"] == "Timmy Operator"
|
|
assert len(data["checklist"]) == 8
|