Skip to content

Commit 4082eb9

Browse files
authored
Test lowercase NIE prefixes and checksum rejection
1 parent 45e9a6a commit 4082eb9

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/i18n/test_es.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ def test_returns_true_on_valid_nie(value: str):
6363
assert es_nie(value)
6464

6565

66+
@pytest.mark.parametrize("validate", [es_nie, es_doi])
67+
@pytest.mark.parametrize("value", ["X0095892M", "Y2584969J", "Z2915723H"])
68+
def test_nie_accepts_lowercase_prefix(validate: Callable[[str], object], value: str):
69+
"""Accept lowercase NIE prefixes consistently with NIF and CIF letters."""
70+
assert validate(value[0].lower() + value[1:]) is True
71+
assert validate(value.lower()) is True
72+
73+
74+
@pytest.mark.parametrize("validate", [es_nie, es_doi])
75+
@pytest.mark.parametrize("value", ["x0095892x", "y2584969x", "z2915723x"])
76+
def test_lowercase_nie_still_checks_checksum(validate: Callable[[str], object], value: str):
77+
"""Do not accept an invalid checksum after normalizing the prefix."""
78+
assert isinstance(validate(value), ValidationError)
79+
80+
6681
@pytest.mark.parametrize(
6782
("value",),
6883
[

0 commit comments

Comments
 (0)