34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from bot_digitador.core.csv_rules import (
|
|
convert_date,
|
|
detect_csv_delimiter,
|
|
format_money_for_input,
|
|
parse_money,
|
|
valid_document_types,
|
|
)
|
|
|
|
|
|
HEADERS = "radicado|documento|ingreso|total_cargos|autorizacion|tipo_documento|tipo_servicio|copago|cuota_moderadora\n"
|
|
|
|
|
|
def test_detects_pipe_csv(tmp_path):
|
|
source = tmp_path / "input.csv"
|
|
source.write_text(HEADERS + "R1|123|2026-08-30|100|A|CC|ambulatorio|0|0\n", encoding="utf-8")
|
|
assert detect_csv_delimiter(str(source), preferred=",") == "|"
|
|
|
|
|
|
def test_dates_and_money_match_original_rules():
|
|
assert convert_date("30/08/2026", "dd/mm/yyyy") == ("08302026", True)
|
|
assert convert_date("2026-08-30", "dd/mm/yyyy") == ("08302026", True)
|
|
assert parse_money("$ 12.500") == 12500.0
|
|
assert parse_money("12,50") == 12.5
|
|
assert format_money_for_input("12,50") == "12,5"
|
|
|
|
|
|
def test_document_candidates_preserve_strategy_rules():
|
|
candidates = valid_document_types("1234567890")
|
|
assert {"CC", "TI", "RC", "CN", "AS", "ME", "PS"}.issubset(candidates)
|
|
assert valid_document_types("") == []
|
|
|