Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_pe_cui.doctest
blob: 9ae7ddef42cfd50c99925051f32fe3effe42ae68 (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
test_pe_cui.doctest - more detailed doctests for stdnum.pe.cui module

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

>>> from stdnum.pe import cui


Tests for some corner cases.

>>> cui.validate('10812543-3')
'108125433'
>>> cui.validate('10812543-H')
'10812543H'
>>> cui.validate('1081254332')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> cui.validate('108125H3-3')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> cui.to_ruc('10812543-3')
'10108125433'


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

>>> numbers = '''
...
...
... 05209244-8
... 05337812-4
... 06009893-5
... 06224656-7
... 06416641-2
... 06477277-1
... 06770169-6
... 07750457-1
... 07881352-6
... 09482447-3
... 09537333-5
... 10117410-2
... 10123558-6
... 10586119B
... 17859853-3
... 25465832-0
... 25543680E
... 25735046-6
... 32023446H
... 33562458-6
... 40812023-9
... 42189197-0
... 42388604-3
... 43381907-7
... 43451826-7
... 45055499E
... 46788632-6
... 46967914-0
... 47205319-7
... 474996072
... 63109177-1
... 70025425-4
... 71347545-4
... 72641234-6
... 72859897-8
...
... '''
>>> [x for x in numbers.splitlines() if x and not cui.is_valid(x)]
[]