Spaces:
Runtime error
Runtime error
File size: 1,632 Bytes
aad7814 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | from backend.core.notes_keyword_router import classify_note_cascade
from backend.core.notes_routing import parse_explicit_section_prefix
def test_explicit_prefix_comma():
assert parse_explicit_section_prefix("G1, garage roof pitched design") == (
"G1",
"garage roof pitched design",
)
def test_explicit_prefix_colon():
assert parse_explicit_section_prefix("D9: External walls with step cracking") == (
"D9",
"External walls with step cracking",
)
def test_explicit_prefix_dash():
assert parse_explicit_section_prefix("D4 - cavity wall with render loss") == (
"D4",
"cavity wall with render loss",
)
def test_cascade_external_walls_routes_d4():
sid, score, body = classify_note_cascade(
"External walls: 300mm cavity wall construction with step cracking"
)
assert sid == "D4"
assert score == 1.0
assert "cavity wall" in body.lower()
def test_cascade_rainwater_routes_d3_not_d4():
sid, _, _ = classify_note_cascade(
"Rainwater fittings: UPVC gutters and gullies present. Rainwater downpipe discharges below ground."
)
assert sid == "D3"
def test_cascade_g1_prefix_strips_and_routes_g1():
sid, score, body = classify_note_cascade("G1, garage roof pitched design with concrete tiles")
assert sid == "G1"
assert score == 1.0
assert body == "garage roof pitched design with concrete tiles"
assert not body.upper().startswith("G1")
def test_cascade_g1_garage_roof_not_d2():
sid, _, _ = classify_note_cascade("Garage roof pitched design with concrete tiles")
assert sid == "G1"
|