- Update marketplace_product_fixtures to create translations - Update test_marketplace_product.py for translation-based titles - Update test_product.py for effective property tests - Update test_order.py to use get_title() method - Add comprehensive CSV processor tests for translations - Update stats service tests for new flat response structure - Fix product schema tests with required marketplace_product_id field - Add helper function create_marketplace_product_with_translation() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
# tests/unit/utils/test_data_validation.py
|
|
import pytest
|
|
|
|
from app.utils.data_processing import GTINProcessor, PriceProcessor
|
|
|
|
|
|
@pytest.mark.unit
|
|
class TestDataValidation:
|
|
def test_gtin_normalization_edge_cases(self):
|
|
"""Test GTIN normalization with edge cases"""
|
|
processor = GTINProcessor()
|
|
|
|
# Test with leading zeros
|
|
assert processor.normalize("000123456789") == "000123456789"
|
|
|
|
# Test with spaces
|
|
assert processor.normalize("123 456 789 012") == "123456789012"
|
|
|
|
# Test with dashes
|
|
assert processor.normalize("123-456-789-012") == "123456789012"
|
|
|
|
# Test very long numbers
|
|
long_number = "1234567890123456789"
|
|
normalized = processor.normalize(long_number)
|
|
assert len(normalized) <= 14 # Should be truncated
|
|
|
|
def test_price_parsing_edge_cases(self):
|
|
"""Test price parsing with edge cases"""
|
|
processor = PriceProcessor()
|
|
|
|
# Test with multiple decimal places
|
|
price, currency = processor.parse_price_currency("12.999 EUR")
|
|
assert price == "12.999"
|
|
|
|
# Test with no currency
|
|
price, currency = processor.parse_price_currency("15.50")
|
|
assert price == "15.50"
|
|
|
|
# Test with unusual formatting
|
|
price, currency = processor.parse_price_currency("EUR 25,50")
|
|
assert currency == "EUR"
|
|
assert price == "25.50" # Comma should be converted to dot
|
|
|
|
def test_input_sanitization(self):
|
|
"""Test input sanitization"""
|
|
# These tests would verify that inputs are properly sanitized
|
|
# to prevent SQL injection, XSS, etc.
|
|
# Implementation would depend on your sanitization logic
|