Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_iban.doctest
blob: b2d91b8ff9901dcf92535f2763c94905c3df3d07 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
test_iban.doctest - more detailed doctests for the stdnum.iban module

Copyright (C) 2011-2015 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.iban module. It
tries to test more corner cases and detailed functionality that is not
really useful as module documentation.

>>> from stdnum import iban


These should all be valid numbers and are from the IBAN REGISTRY as sample
numbers:

>>> numbers = '''
... AD12 0001 2030 2003 5910 0100
... AD1200012030200359100100
... AE070331234567890123456
... AL47 2121 1009 0000 0002 3569 8741
... AL47212110090000000235698741
... AT61 1904 3002 3457 3201
... AT611904300234573201
... AZ21NABZ00000000137010001944
... BA39 1290 0794 0102 8494
... BA391290079401028494
... BE68 5390 0754 7034
... BE68539007547034
... BG80 BNBG 9661 1020 3456 78
... BG80BNBG96611020345678
... BH67BMAG00001299123456
... BR1800000000141455123924100C2
... BR9700360305000010009795493P1
... CH93 0076 2011 6238 5295 7
... CH9300762011623852957
... CR0515202001026284066
... CY17 0020 0128 0000 0012 0052 7600
... CY17002001280000001200527600
... CZ65 0800 0000 1920 0014 5399
... CZ6508000000192000145399
... CZ94 5500 0000 0010 1103 8930
... CZ9455000000001011038930
... DE89 3704 0044 0532 0130 00
... DE89370400440532013000
... DK50 0040 0440 1162 43
... DK5000400440116243
... DO28BAGR00000001212453611324
... EE38 2200 2210 2014 5685
... EE382200221020145685
... ES91 2100 0418 4502 0005 1332
... ES9121000418450200051332
... FI21 1234 5600 0007 85
... FI2112345600000785
... FI5542345670000081
... FO62 6460 0001 6316 34
... FO6264600001631634
... FR14 2004 1010 0505 0001 3M02 606
... FR1420041010050500013M02606
... GB29 NWBK 6016 1331 9268 19
... GB29NWBK60161331926819
... GE29 NB00 0000 0101 9049 17
... GE29NB0000000101904917
... GI75 NWBK 0000 0000 7099 453
... GI75NWBK000000007099453
... GL89 6471 0001 0002 06
... GL8964710001000206
... GR16 0110 1250 0000 0001 2300 695
... GR1601101250000000012300695
... GT82TRAJ01020000001210029690
... HR12 1001 0051 8630 0016 0
... HR1210010051863000160
... HU42 1177 3016 1111 1018 0000 0000
... HU42117730161111101800000000
... IE29 AIBK 9311 5212 3456 78
... IE29AIBK93115212345678
... IL62 0108 0000 0009 9999 999
... IL620108000000099999999
... IS14 0159 2600 7654 5510 7303 39
... IS140159260076545510730339
... IT60 X054 2811 1010 0000 0123 456
... IT60X0542811101000000123456
... JO94CBJO0010000000000131000302
... KZ86125KZT5004100100
... LB62 0999 0000 0001 0019 0122 9114
... LB62099900000001001901229114
... LI21 0881 0000 2324 013A A
... LI21088100002324013AA
... LT12 1000 0111 0100 1000
... LT121000011101001000
... LU28 0019 4006 4475 0000
... LU280019400644750000
... LV80 BANK 0000 4351 9500 1
... LV80BANK0000435195001
... MC11 1273 9000 7000 1111 1000 h79
... MC1112739000700011111000h79
... MD24AG000225100013104168
... ME25 5050 0001 2345 6789 51
... ME25505000012345678951
... MK072 5012 0000 0589 84
... MK07250120000058984
... MR13 0002 0001 0100 0012 3456 753
... MR1300020001010000123456753
... MT84 MALT 0110 0001 2345 MTLC AST0 01S
... MT84MALT011000012345MTLCAST001S
... MU17 BOMM 0101 1010 3030 0200 000M UR
... MU17 BOMM0101101030300200000MUR
... NL91 ABNA 0417 1643 00
... NL91ABNA0417164300
... NO93 8601 1117 947
... NO9386011117947
... PK36SCBL0000001123456702
... PL61 1090 1014 0000 0712 1981 2874
... PL61109010140000071219812874
... PS92PALS000000000400123456702
... PT50 0002 0123 1234 5678 9015 4
... PT50000201231234567890154
... QA58DOHB00001234567890ABCDEFG
... RO49 AAAA 1B31 0075 9384 0000
... RO49AAAA1B31007593840000
... RS35 2600 0560 1001 6113 79
... RS35260005601001611379
... SA03 8000 0000 6080 1016 7519
... SA0380000000608010167519
... SE45 5000 0000 0583 9825 7466
... SE4550000000058398257466
... SI56 1910 0000 0123 438
... SI56191000000123438
... SK31 1200 0000 1987 4263 7541
... SK3112000000198742637541
... SM86 U032 2509 8000 0000 0270 100
... SM86U0322509800000000270100
... TL 38 008 00123456789101 57
... TN59 1000 6035 1835 9847 8831
... TN5910006035183598478831
... TR33 0006 1005 1978 6457 8413 26
... TR330006100519786457841326
... VG96VPVG0000012345678901
... XK051212012345678906
... '''
>>> [ x for x in numbers.splitlines() if x and not iban.is_valid(x) ]
[]


These all have broken checksums or are mangled:

>>> numbers = '''
... AL48212110090000000235698741
... AD1210012030200359100100
... AT611804300234573201
... BE68530907547034
... BA391290709401028494
... BG80BNBG99611020345678
... HR1210010052863000160
... CY17002001281000001200527600
... CZ6508000000129000145399
... CZ9455000000000101038930
... DK5000400440116342
... '''
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]


These are the wrong length but otherwise have valid checksums:

>>> numbers = '''
... AD48 0001 2030 2003 5910 01
... AT93 1904 3002 3457 3201 99
... BE36 5390 0754 7034 1234
... BA30 1290 0794 0102 84
... '''
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]


These are mostly valid except that they have alphabetic characters where
they are not allowed or numbers where alphabetic characters are expected
or have an unknown country code:

>>> numbers = '''
... BG93 BNBG 9661 1A20 3456 78
... GI22 NW3K 0000 0000 7099 453
... NL56 3003 0A17 1643 00
... QQ93 1234 5678
... '''
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]