Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_ar_cbu.doctest
blob: 151600e92eba1c38ea1f0a560e797eeb74459989 (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
test_ar_cbu.doctest - more detailed doctests for the stdnum.ar.cbu module

Copyright (C) 2016 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.ar.cbu module. It
tries to validate a number of numbers that have been found online.

>>> from stdnum.ar import cbu
>>> from stdnum.exceptions import *


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

>>> numbers = '''
...
... 0 0 7 0 9 9 9 0 2 0 0 0 0 0 6 5 7 0 6 0 8 0
... 0 1 1 0 4 3 3 6 3 0 0 4 3 3 1 3 8 5 7 6 8 3
... 0 1 4 0 3 3 9 6   0 1 6 3 0 2 0 1 3 8 1 2 7 6
... 0 1400 236 – 01 5068 0262 5874
... 0 4 4 0 0 6 4 – 6 – 4 0 0 0 0 1 4 2 9 4 1 0 9 – 2
... 0 7 2 0 1 4 6 8 2 0 0 0 0 0 0 1 0 6 2 3 4 0
... 0 7 2 0 1 6 8 0 2 0 0 0 0 0 0 1 1 8 3 2 3 6
... 0 7 2 0 3 8 0 8 8 8 0 0 0 0 3 5 5 3 3 9 6 8
... 0070090020000004146504
... 0110097630009704213797
... 0140339601630201381276
... 0140351801684605023087
... 0168888-1-0000827441015-8
... 01703342 – 200 000 3036 7766
... 0200915901000000274233
... 03400562 00560007577005
... 0720079388000035942322
... 0940099324001313220028
... 1 5 0 0 0 0 6 0 0 0 0 0 5 6 6 0 4 4 7 2 0 0
... 1 5 0 0 0 8 7 9 - 0 0 0 5 1 3 3 2 0 7 5 1 9 - 6
... 1 9 1 0 1 1 9 6   5 5 0 1 1 9 0 1 0 8 4 6 4 6
... 2850590940090418135201
...
... '''
>>> [x for x in numbers.splitlines() if x and not cbu.is_valid(x)]
[]


More detailed tests:

>>> cbu.validate('285059094009041')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> cbu.validate('A850590940090418135201')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> cbu.validate('0940099324001313220028')
'0940099324001313220028'
>>> cbu.validate('1940099324001313220028')  # error in first part
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> cbu.validate('0940099324001313220038')  # error in second part
Traceback (most recent call last):
    ...
InvalidChecksum: ...