Re-structure the project.
This commit is contained in:
108
tests/normalize/normalizers/test_amount_normalizer.py
Normal file
108
tests/normalize/normalizers/test_amount_normalizer.py
Normal file
@@ -0,0 +1,108 @@
|
||||
"""
|
||||
Tests for AmountNormalizer
|
||||
|
||||
Usage:
|
||||
pytest tests/normalize/normalizers/test_amount_normalizer.py -v
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from src.normalize.normalizers.amount_normalizer import AmountNormalizer
|
||||
|
||||
|
||||
class TestAmountNormalizer:
|
||||
"""Test AmountNormalizer functionality"""
|
||||
|
||||
@pytest.fixture
|
||||
def normalizer(self):
|
||||
"""Create normalizer instance for testing"""
|
||||
return AmountNormalizer()
|
||||
|
||||
def test_integer_amount(self, normalizer):
|
||||
"""Integer amount should generate decimal variants"""
|
||||
result = normalizer.normalize('114')
|
||||
assert '114' in result
|
||||
assert '114,00' in result
|
||||
assert '114.00' in result
|
||||
|
||||
def test_with_comma_decimal(self, normalizer):
|
||||
"""Amount with comma decimal should generate dot variant"""
|
||||
result = normalizer.normalize('114,00')
|
||||
assert '114,00' in result
|
||||
assert '114.00' in result
|
||||
assert '114' in result
|
||||
|
||||
def test_with_dot_decimal(self, normalizer):
|
||||
"""Amount with dot decimal should generate comma variant"""
|
||||
result = normalizer.normalize('114.00')
|
||||
assert '114.00' in result
|
||||
assert '114,00' in result
|
||||
|
||||
def test_with_space_thousand_separator(self, normalizer):
|
||||
"""Amount with space as thousand separator should be normalized"""
|
||||
result = normalizer.normalize('1 234,56')
|
||||
assert '1234,56' in result
|
||||
assert '1234.56' in result
|
||||
|
||||
def test_space_as_decimal_separator(self, normalizer):
|
||||
"""Space as decimal separator (Swedish format) should be normalized"""
|
||||
result = normalizer.normalize('3045 52')
|
||||
assert '3045.52' in result
|
||||
assert '3045,52' in result
|
||||
assert '304552' in result
|
||||
|
||||
def test_us_format(self, normalizer):
|
||||
"""US format (1,390.00) should generate variants"""
|
||||
result = normalizer.normalize('1,390.00')
|
||||
assert '1390.00' in result
|
||||
assert '1390,00' in result
|
||||
assert '1390' in result
|
||||
|
||||
def test_european_format(self, normalizer):
|
||||
"""European format (1.390,00) should generate variants"""
|
||||
result = normalizer.normalize('1.390,00')
|
||||
assert '1390.00' in result
|
||||
assert '1390,00' in result
|
||||
assert '1390' in result
|
||||
|
||||
def test_space_thousand_with_decimal(self, normalizer):
|
||||
"""Space thousand separator with decimal should be normalized"""
|
||||
result = normalizer.normalize('10 571,00')
|
||||
assert '10571.00' in result
|
||||
assert '10571,00' in result
|
||||
|
||||
def test_removes_currency_symbols(self, normalizer):
|
||||
"""Currency symbols (kr, SEK) should be removed"""
|
||||
result = normalizer.normalize('114 kr')
|
||||
assert '114' in result
|
||||
assert '114,00' in result
|
||||
|
||||
def test_large_amount_european_format(self, normalizer):
|
||||
"""Large amount in European format should be handled"""
|
||||
result = normalizer.normalize('20.485,00')
|
||||
assert '20485.00' in result
|
||||
assert '20485,00' in result
|
||||
|
||||
def test_empty_string(self, normalizer):
|
||||
"""Empty string should return empty list"""
|
||||
result = normalizer('')
|
||||
assert result == []
|
||||
|
||||
def test_none_value(self, normalizer):
|
||||
"""None value should return empty list"""
|
||||
result = normalizer(None)
|
||||
assert result == []
|
||||
|
||||
def test_callable_interface(self, normalizer):
|
||||
"""Normalizer should be callable via __call__"""
|
||||
result = normalizer('1234.56')
|
||||
assert '1234.56' in result
|
||||
|
||||
def test_removes_sek_suffix(self, normalizer):
|
||||
"""SEK suffix should be removed"""
|
||||
result = normalizer.normalize('1234 SEK')
|
||||
assert '1234' in result
|
||||
|
||||
def test_with_colon_dash_suffix(self, normalizer):
|
||||
"""Colon-dash suffix should be removed"""
|
||||
result = normalizer.normalize('1234:-')
|
||||
assert '1234' in result
|
||||
Reference in New Issue
Block a user