Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_do_rnc.doctest
blob: 80c35754ef5ed7897d3c4088eed0f9b7a1a605a1 (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
154
155
156
157
158
159
160
161
162
163
164
165
test_do_rnc.doctest - more detailed doctests for stdnum.do.rnc module

Copyright (C) 2015-2017 Arthur de Jong

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.do.rnc module. It
tries to cover more corner cases and detailed functionality that is not
really useful as module documentation.

>>> from stdnum.do import rnc


Some basic tests for invalid numbers:

>>> rnc.validate('12345678')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> rnc.validate('1234567890')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> rnc.validate('123456789012')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> rnc.validate('acvbnmkjh')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> rnc.validate('122011226')
'122011226'
>>> rnc.validate('112031226')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> rnc.validate('101637587')
'101637587'


These have been found online and should all be valid numbers.

>>> numbers = '''
...
... 10233317
... 501050302
... 501249532
... 501275452
... 501402772
... 501406832
... 501423982
... 501430482
... 501456252
... 501464492
... 501470042
... 501494502
... 501494812
... 501496882
... 501670912
... 501676936
... 501690832
... 501896112
... 501925082
... 501934782
... 502004222
... 502500262
... 502571062
... 502599382
... 502601972
... 502612532
... 502614012
... 502614802
... 502858272
... 502860692
... 502866062
... 502867182
... 502871732
... 502872372
... 502873972
... 502876882
... 502879652
... 502880022
... 502880162
... 502887132
... 502889232
... 502890842
... 502894112
... 503972922
... 503995752
... 504065782
... 505030302
... 505038532
... 505063502
... 505072412
... 505613472
... 505613502
... 505613782
... 505621912
... 505622552
... 507032262
... 507883262
... 511104382
... 511106822
... 512924072
... 514026622
... 514035672
... 515121792
... 515123442
... 519505672
... 522004242
... 523006132
... 523012132
... 523013422
... 523014062
... 523015212
... 523017622
... 523021182
... 523022162
... 523022952
... 523023592
... 524001842
... 524001982
... 524007352
... 524010892
... 525001772
... 525001802
... 530001932
... 531009502
... 531030722
... 531032342
... 531035562
... 531039622
... 531042232
... 531043182
... 531054192
... 531056152
... 531073022
... 531081602
... 531085012
... 531091322
... 531096782
... 531132312
... 531136032
... 531136962
... 531137012
... 531137152
...
... '''
>>> [x for x in numbers.splitlines() if x and not rnc.is_valid(x)]
[]