Spaces:
Runtime error
Runtime error
Download tests/test_mapping.py from Bubbles30/RemittanceVerifier: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/Bubbles30/RemittanceVerifier/resolve/main/tests/test_mapping.py
- Command line
-
hf download hf://spaces/Bubbles30/RemittanceVerifier/tests/test_mapping.py
-
curl -L -o test_mapping.py https://huggingface.co/spaces/Bubbles30/RemittanceVerifier/resolve/main/tests/test_mapping.py
1.42 kB
| from pathlib import Path | |
| from invoice_reconciler.mapping import FieldMapping, records_from_table, suggest_mapping | |
| from invoice_reconciler.parsers import parse_file | |
| FIXTURES = Path(__file__).parent / "fixtures" | |
| def test_suggest_mapping_prefers_gross_not_first_money_column(): | |
| columns = ["Invoice Number", "Adjustment", "Gross Amount", "Net Amount"] | |
| suggestion = suggest_mapping(columns) | |
| assert suggestion.invoice_column == "Invoice Number" | |
| # Must suggest Gross Amount, not Adjustment (first monetary-looking col) | |
| assert suggestion.amount_column == "Gross Amount" | |
| assert "Gross Amount" in suggestion.amount_candidates | |
| def test_never_auto_pick_first_monetary_by_scanning_values(): | |
| """Without amount-like headers, amount_column suggestion stays None.""" | |
| columns = ["ColA", "ColB", "ColC"] | |
| suggestion = suggest_mapping(columns) | |
| assert suggestion.amount_column is None | |
| assert suggestion.invoice_column is None | |
| def test_records_use_selected_gross_column(): | |
| table = parse_file(FIXTURES / "source.csv") | |
| # If Net were wrongly chosen, INV-100 would be 1233.50 | |
| mapping = FieldMapping(invoice_column="Invoice Number", amount_column="Gross Amount") | |
| records = records_from_table(table, mapping) | |
| by_inv = {r.invoice_number: r for r in records if r.invoice_number} | |
| assert by_inv["INV-100"].amount is not None | |
| assert str(by_inv["INV-100"].amount) == "1234.50" | |