Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_eu_oss.doctest
blob: 23889a49b197edb78b244b1627a1c1dc88d64076 (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
test_eu_oss.doctest - more detailed doctests for the stdnum.eu.oss module

Copyright (C) 2023 Arthur de Jong
Copyright (C) 2023 Sergi Almacellas Abellana

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.eu.oss module.

>>> from stdnum.eu import oss

#>>> from stdnum.exceptions import *


Extra tests for some corner cases.

>>> oss.validate('AA826010755')  # first digits wrong
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> oss.validate('EU372A22452')  # some digits not numeric
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> oss.validate('EU123010755')  # MSI wrong
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> oss.validate('EU3720000224')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> oss.validate('IM372022452')
Traceback (most recent call last):
    ...
InvalidLength: ...



These have been found online and should all be valid numbers. Interestingly
the VIES VAT number validation does not support validating numbers issued
under the non-union or import schemes.

https://en.wikipedia.org/wiki/VAT_identification_number also lists
EU826010755 for Godaddy and EU826009064 for AWS but neither seem to be valid.

>>> numbers = '''
...
... EU372022452
... IM3720000224
...
... '''
>>> [x for x in numbers.splitlines() if x and not oss.is_valid(x)]
[]