blob: 1b730ec2df03fbc32a9ef6b700e329e8458322d5 (
plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
test_ke_pin.doctest - more detailed doctests for stdnum.ke.pin module
Copyright (C) 2022 Leandro Regueiro
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
This file contains more detailed doctests for the stdnum.ke.pin module. It
tries to test more corner cases and detailed functionality that is not really
useful as module documentation.
>>> from stdnum.ke import pin
Tests for some corner cases.
>>> pin.validate('A006665913Y')
'A006665913Y'
>>> pin.validate('P 051193029-r')
'P051193029R'
>>> pin.format('P 051193029-r')
'P051193029R'
>>> pin.validate('12345')
Traceback (most recent call last):
...
InvalidLength: ...
>>> pin.validate('X1234567897')
Traceback (most recent call last):
...
InvalidFormat: ...
These have been found online and should all be valid numbers.
>>> numbers = '''
...
... A001906275H
... A003364162P
... A004690554X
... A004764821W
... A005171423w
... A008965081L
... A010165600X
... A014678229G
... A015002408V
... P000591575X
... P000592118K
... P000592265X
... P000592366Z
... P000592851X
... P000593471Z
... P000593916S
... P000595037X
... P000595362D
... P000595438C
... P000595467J
... P000596373I
... P000596967Q
... P000597143A
... P000597694S
... P000598224A
... P000598330Z
... P000598522B
... P000599642I
... P000600314X
... P000602904I
... P000602920I
... P000603130E
... P000603639S
... P000604053O
... P000605255W
... P000605674D
... P000607839E
... P000608167F
... P000609340W
... P000609345B
... P000609346C
... P000609356G
... P000609360C
... P000609361D
... P000609362E
... P000609364G
... P000609365H
... P000609367J
... P000609370E
... P000609661G
... P000609671I
... P000611951N
... P000611975V
... P000612067R
... P000612260M
... P000612829R
... P000613824O
... P000615058Y
... P000619379O
... P000619594P
... P051092778I
... P051092962C
... P051094112J
... P051094227U
... P051094522S
... P051100248H
... P051100289S
... P051102426H
... P051102575T
... P051104242J
... P051106014G
... P051112430E
... P051116151S
... P051117306P
... P051123493Y
... P051124237Z
... P051124533N
... P051141061H
... P051149832D
... P051151506E
... P051153177Y
... P051153543Q
... P051155350V
... P051160236J
... P051170839T
... P051172781A
... P051332840T
... P051351120F
... P051365947M
... P051391353w
... P051474338E
... P051603577M
... P051647363S
... P051675891A
... P051828116I
... P051855612G
... P051909085B
... P051912053E
... p051606652M
... p051896085c
...
... '''
>>> [x for x in numbers.splitlines() if x and not pin.is_valid(x)]
[]
|