Files
pdf_oralia_vibe/tests/test_amounts.py
Bertrand Benjamin d42bfecab4 chore: ajoute ruff (lint) et corrige les violations
- Config ruff dans pyproject.toml : règles E/W/F/I/UP/B, whitelist des appels
  d'injection FastAPI (Depends/File/Form/Query) pour B008, B904 ignoré
  (traduction volontaire des exceptions en réponses HTTP)
- Auto-fixes : tri des imports, suppression d'imports inutilisés, annotations
  PEP 604, f-strings sans placeholder, modes open redondants
- Suppression de variables inutilisées (config.reset_setting, parser locataires)

ruff check . : All checks passed ; 61 tests OK

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 10:20:36 +02:00

40 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Tests du parsing des montants français."""
import pytest
from plesna_gerance.utils.amounts import extract_amounts_from_line, parse_amount
@pytest.mark.parametrize(
"text,expected",
[
("123,45", 123.45),
("123.45", 123.45),
("1 234,56", 1234.56),
("1.234,56", 1234.56),
("1 234,56", 1234.56),
("123,45 €", 123.45),
("", 0.0),
("abc", 0.0),
("-45,67", -45.67),
],
)
def test_parse_amount(text, expected):
assert parse_amount(text) == pytest.approx(expected)
def test_extract_amounts_ignores_dates():
# 01.01.25 est une date, pas un montant
line = "Loyer du 01.01.25 au 31.01.25 : 500,00 réglé 500,00"
amounts = extract_amounts_from_line(line)
assert amounts == [500.00, 500.00]
def test_extract_amounts_negative_and_thousands():
line = "Solde -1 234,56 et frais 12,00"
assert extract_amounts_from_line(line) == [-1234.56, 12.00]
def test_extract_amounts_none_found():
assert extract_amounts_from_line("aucun montant ici") == []