bmc_hub/tests/test_ollama_amount_normalization.py

20 lines
615 B
Python
Raw Normal View History

from app.services.ollama_service import OllamaService
def test_normalizes_numeric_and_danish_amount_values():
normalize = OllamaService._normalize_amount_value
assert normalize(1471.2) == 1471.2
assert normalize("1471.20") == 1471.2
assert normalize("1.471,20 DKK") == 1471.2
assert normalize("-1 471,20 kr.") == -1471.2
def test_rejects_non_amount_values_without_type_errors():
normalize = OllamaService._normalize_amount_value
assert normalize(None) is None
assert normalize("") is None
assert normalize("ukendt") is None
assert normalize({"value": "10,00"}) is None