"""
Tests for CustomerNumberNormalizer

Usage:
    pytest tests/normalize/normalizers/test_customer_number_normalizer.py -v
"""

import pytest
from shared.normalize.normalizers.customer_number_normalizer import CustomerNumberNormalizer


class TestCustomerNumberNormalizer:
    """Test CustomerNumberNormalizer functionality"""

    @pytest.fixture
    def normalizer(self):
        """Create normalizer instance for testing"""
        return CustomerNumberNormalizer()

    def test_alphanumeric_with_space_and_dash(self, normalizer):
        """Customer number with space and dash should generate variants"""
        result = normalizer.normalize('EMM 256-6')
        assert 'EMM 256-6' in result
        assert 'EMM256-6' in result
        assert 'EMM2566' in result

    def test_alphanumeric_with_space(self, normalizer):
        """Customer number with space should generate variants"""
        result = normalizer.normalize('ABC 123')
        assert 'ABC 123' in result
        assert 'ABC123' in result

    def test_case_variants(self, normalizer):
        """Should generate uppercase and lowercase variants"""
        result = normalizer.normalize('Emm 256-6')
        assert 'EMM 256-6' in result
        assert 'emm 256-6' in result

    def test_pure_number(self, normalizer):
        """Pure number customer number should be handled"""
        result = normalizer.normalize('12345')
        assert '12345' in result

    def test_with_only_dash(self, normalizer):
        """Customer number with only dash should generate no-dash variant"""
        result = normalizer.normalize('ABC-123')
        assert 'ABC-123' in result
        assert 'ABC123' in result

    def test_with_only_space(self, normalizer):
        """Customer number with only space should generate no-space variant"""
        result = normalizer.normalize('ABC 123')
        assert 'ABC 123' in result
        assert 'ABC123' 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('EMM 256-6')
        assert 'EMM2566' in result

    def test_all_uppercase(self, normalizer):
        """All uppercase should not duplicate uppercase variant"""
        result = normalizer.normalize('ABC123')
        uppercase_count = sum(1 for v in result if v == 'ABC123')
        assert uppercase_count == 1

    def test_complex_customer_number(self, normalizer):
        """Complex customer number with multiple separators"""
        result = normalizer.normalize('ABC-123 XYZ')
        assert 'ABC-123 XYZ' in result
        assert 'ABC123XYZ' in result

    def test_swedish_customer_numbers(self, normalizer):
        """Swedish customer number formats should be handled"""
        result = normalizer.normalize('UMJ 436-R')
        assert 'UMJ 436-R' in result
        assert 'UMJ436-R' in result
        assert 'UMJ436R' in result
        assert 'umj 436-r' in result
