# tests/test_utils.py import pytest from utils.data_processing import GTINProcessor, PriceProcessor class TestGTINProcessor: def setup_method(self): self.processor = GTINProcessor() def test_normalize_valid_gtin(self): # Test EAN-13 assert self.processor.normalize("1234567890123") == "1234567890123" # Test UPC-A assert self.processor.normalize("123456789012") == "123456789012" # Test with decimal assert self.processor.normalize("123456789012.0") == "123456789012" def test_normalize_invalid_gtin(self): assert self.processor.normalize("") is None assert self.processor.normalize(None) is None assert self.processor.normalize("abc") is None assert self.processor.normalize("123") == "000000000123" # Padded to 12 digits def test_validate_gtin(self): assert self.processor.validate("1234567890123") is True assert self.processor.validate("123456789012") is True assert self.processor.validate("12345678") is True assert self.processor.validate("123") is False assert self.processor.validate("") is False class TestPriceProcessor: def setup_method(self): self.processor = PriceProcessor() def test_parse_price_currency(self): # Test EUR with symbol price, currency = self.processor.parse_price_currency("8.26 EUR") assert price == "8.26" assert currency == "EUR" # Test USD with symbol price, currency = self.processor.parse_price_currency("$12.50") assert price == "12.50" assert currency == "USD" # Test with comma decimal separator price, currency = self.processor.parse_price_currency("8,26 €") assert price == "8.26" assert currency == "EUR" def test_parse_invalid_price(self): price, currency = self.processor.parse_price_currency("") assert price is None assert currency is None price, currency = self.processor.parse_price_currency(None) assert price is None assert currency is None