from pathlib import Path

SCRIPT = Path('scripts/audit_operator_page_consistency.py').read_text(encoding='utf-8')


def test_raw_event_errors_only_count_unresolved_rows():
    assert 'unresolved_error_raws' in SCRIPT
    assert 'not r.get("processed") or not _s(r.get("message_id"))' in SCRIPT
    assert 'raw_events_processing_error_for_linked_conversation' in SCRIPT


def test_historical_processing_error_is_not_counted_unconditionally():
    old_pattern = 'if any(_s(r.get("processing_error")) for r in raws)'
    assert old_pattern not in SCRIPT
