-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathtest_es.py
More file actions
131 lines (117 loc) · 2.67 KB
/
test_es.py
File metadata and controls
131 lines (117 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""Test i18n/es."""
# external
import pytest
# local
from validators import ValidationError, es_cif, es_doi, es_nie, es_nif
@pytest.mark.parametrize(
("value",),
[
("B25162520",),
("U4839822F",),
("B96817697",),
("P7067074J",),
("Q7899705C",),
("C75098681",),
("G76061860",),
("C71345375",),
("G20558169",),
("U5021960I",),
],
)
def test_returns_true_on_valid_cif(value: str):
"""Test returns true on valid cif."""
assert es_cif(value)
@pytest.mark.parametrize(
("value",),
[
("12345",),
("ABCDEFGHI",),
("Z5021960I",),
],
)
def test_returns_false_on_invalid_cif(value: str):
"""Test returns false on invalid cif."""
result = es_cif(value)
assert isinstance(result, ValidationError)
@pytest.mark.parametrize(
("value",),
[
("X0095892M",),
("X8868108K",),
("X2911154K",),
("Y2584969J",),
("X7536157T",),
("Y5840388N",),
("Z2915723H",),
("Y4002236C",),
("X7750702R",),
("Y0408759V",),
],
)
def test_returns_true_on_valid_nie(value: str):
"""Test returns true on valid nie."""
assert es_nie(value)
@pytest.mark.parametrize(
("value",),
[
("K0000023T",),
("L0000024R",),
("M0000025W",),
("00000026A",),
("00000027G",),
("00000028M",),
("00000029Y",),
("00000030F",),
("00000031P",),
("00000032D",),
("00000033X",),
("00000034B",),
("00000035N",),
("00000036J",),
("00000037Z",),
("00000038S",),
("00000039Q",),
("00000040V",),
("00000041H",),
("00000042L",),
("00000043C",),
("00000044K",),
("00000045E",),
],
)
def test_returns_true_on_valid_nif(value: str):
"""Test returns true on valid nif."""
assert es_nif(value)
@pytest.mark.parametrize(
("value",),
[
("12345",),
("X0000000T",),
("00000000T",),
("00000001R",),
],
)
def test_returns_false_on_invalid_nif(value: str):
"""Test returns false on invalid nif."""
result = es_nif(value)
assert isinstance(result, ValidationError)
@pytest.mark.parametrize(
("value",),
[
# CIFs
("B25162520",),
("U4839822F",),
("B96817697",),
# NIEs
("X0095892M",),
("X8868108K",),
("X2911154K",),
# NIFs
("26643189N",),
("07060225F",),
("49166693F",),
],
)
def test_returns_true_on_valid_doi(value: str):
"""Test returns true on valid doi."""
assert es_doi(value)