"""Deliberately-malformed daily-file fragment used to prove the parser skips
bad rows (logged warning, no batch abort) and survives encoding issues.
Three problem rows are embedded:
R1 a floor-bill row with NO bill link / no number -> must skip
R2 a floor-bill row whose item cell is non-numeric garbage-> must skip
R3 a hearing row with no committee AND no date -> must skip
The surrounding rows are valid, so the batch must still yield all valid ones.
"""
VALID = (
'
'
''
'| '
'AB 100 | '
'Smith | '
'An act to do X. | '
'State Capitol | '
'1 | '
'Read third time. | '
'
'
'
'
)
BAD_NO_LINK = (
''
''
'| '
'AB 200 (no hyperlink here) | '
'Jones | '
'Missing bill link row. | '
'2 | '
'
'
'
'
)
BAD_ITEM = (
''
''
'| '
'AB 300 | '
'Lee | '
'Non-numeric item row. | '
'not-a-number | '
'
'
'
'
)
BAD_HEARING = (
''
)
def malformed_document() -> str:
"""A concatenated fragment: valid, bad, bad, bad rows."""
return VALID + BAD_NO_LINK + BAD_ITEM + BAD_HEARING
def write_fixtures(out_dir: str) -> None:
import os
os.makedirs(out_dir, exist_ok=True)
# A clean single-file fixture for the "good" acceptance test.
with open(os.path.join(out_dir, "malformed_fragment.html"), "w", encoding="utf-8") as fh:
fh.write(malformed_document())
# A tiny encoding-edge-case file: UTF-16 with a BOM so the charset path runs.
with open(os.path.join(out_dir, "utf16_sample.html"), "w", encoding="utf-16") as fh:
fh.write(VALID)
if __name__ == "__main__":
write_fixtures(".parser_fixtures")
import sys
print("wrote fixtures to .parser_fixtures/", file=sys.stderr)