from pathlib import Path

SCRIPT = Path('scripts/audit_operator_page_consistency.py')


def test_document_specific_line_total_helpers_exist():
    text = SCRIPT.read_text(encoding='utf-8')
    assert 'def _line_total_for_document' in text
    assert 'def _line_document_tokens' in text
    assert 'jasmin_invoice_lines_total_differs_from_invoice' in text


def test_old_broad_line_total_medium_rules_removed():
    text = SCRIPT.read_text(encoding='utf-8')
    assert 'jasmin_imported_lines_total_differs_from_invoice' not in text
    assert 'jasmin_imported_lines_total_differs_from_quote' not in text
    assert 'Soma das linhas Jasmin importadas não coincide' not in text


def test_ambiguous_broad_totals_are_low_not_medium():
    text = SCRIPT.read_text(encoding='utf-8')
    assert 'jasmin_imported_lines_total_ambiguous_for_invoice' in text
    assert 'add("low", "jasmin_imported_lines_total_ambiguous_for_invoice"' in text
