"""
Tests for BankgiroNormalizer

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

import pytest
from shared.normalize.normalizers.bankgiro_normalizer import BankgiroNormalizer


class TestBankgiroNormalizer:
    """Test BankgiroNormalizer functionality"""

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

    def test_with_dash_8_digits(self, normalizer):
        """8-digit Bankgiro with dash should generate variants"""
        result = normalizer.normalize('5393-9484')
        assert '5393-9484' in result
        assert '53939484' in result

    def test_without_dash_8_digits(self, normalizer):
        """8-digit Bankgiro without dash should generate dash variant"""
        result = normalizer.normalize('53939484')
        assert '53939484' in result
        assert '5393-9484' in result

    def test_7_digits(self, normalizer):
        """7-digit Bankgiro should generate correct format"""
        result = normalizer.normalize('5393948')
        assert '5393948' in result
        assert '539-3948' in result

    def test_with_dash_7_digits(self, normalizer):
        """7-digit Bankgiro with dash should generate variants"""
        result = normalizer.normalize('539-3948')
        assert '539-3948' in result
        assert '5393948' 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('5393-9484')
        assert '53939484' in result

    def test_with_spaces(self, normalizer):
        """Bankgiro with spaces should be normalized"""
        result = normalizer.normalize('5393 9484')
        assert '53939484' in result

    def test_special_dashes(self, normalizer):
        """Different dash types should be normalized to standard hyphen"""
        # en-dash
        result = normalizer.normalize('5393\u20139484')
        assert '5393-9484' in result
        assert '53939484' in result

    def test_with_prefix(self, normalizer):
        """Bankgiro with BG: prefix should be normalized"""
        result = normalizer.normalize('BG:5393-9484')
        assert '53939484' in result

    def test_generates_ocr_variants(self, normalizer):
        """Should generate OCR error variants"""
        result = normalizer.normalize('5393-9484')
        # Should contain multiple variants including OCR corrections
        assert len(result) > 2
