test_py_ruc.doctest - more detailed doctests for stdnum.py.ruc module Copyright (C) 2019 Leandro Regueiro 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.py.ruc module. It tries to test more corner cases and detailed functionality that is not really useful as module documentation. >>> from stdnum.py import ruc Tests for some corner cases. >>> ruc.validate('800280610') '800280610' >>> ruc.validate('80000020-0') '800000200' >>> ruc.format('800001907') '80000190-7' >>> ruc.validate('9991603') '9991603' >>> ruc.validate('2660-3') '26603' >>> ruc.validate('80123456785') Traceback (most recent call last): ... InvalidLength: ... >>> ruc.validate('FF8002121') Traceback (most recent call last): ... InvalidFormat: ... >>> ruc.validate('80021744-8') Traceback (most recent call last): ... InvalidChecksum: ... These have been found online and should all be valid numbers. >>> numbers = ''' ... ... 1068460-3 ... 1070600-3 ... 1075150-5 ... 1086170-0 ... 1120880-5 ... 1152390-5 ... 116840-1 ... 1206910-8 ... 1218000-9 ... 1218400-4 ... 1238600-6 ... 1249160-8 ... 1267110-0 ... 1280950-0 ... 1371610-7 ... 1381630-6 ... 1393200-4 ... 1420870-9 ... 1449540-6 ... 1494600-9 ... 1572440-9 ... 1588230-6 ... 1616440-7 ... 176330-0 ... 1820310-8 ... 1820920-3 ... 1839520-1 ... 1848060-8 ... 1934740-5 ... 2007510-3 ... 2012640-9 ... 2042780-8 ... 2048860-2 ... 2049750-4 ... 2059680-4 ... 2157230-5 ... 2195990-0 ... 2218790-1 ... 2224970-2 ... 2299400-9 ... 2345940-9 ... 2356810-0 ... 2366360-0 ... 2414460-6 ... 244860-2 ... 2498810-3 ... 2513340-3 ... 2634810-1 ... 2863640-6 ... 2874790-9 ... 2889810-9 ... 2908190-4 ... 2951250-6 ... 2997610-3 ... 3196710-8 ... 3206530-2 ... 3330830-6 ... 3387260-0 ... 341160-5 ... 3412130-7 ... 3417980-1 ... 3446170-1 ... 3464340-0 ... 3500120-8 ... 3526270-2 ... 3527940-0 ... 3538680-0 ... 3598580-1 ... 3616260-4 ... 3617350-9 ... 3632060-9 ... 3649750-9 ... 3676210-5 ... 3715270-0 ... 3724170-2 ... 3785560-3 ... 3804540-0 ... 3811470-4 ... 3896270-5 ... 3942870-2 ... 398020-0 ... 3980620-0 ... 3981320-7 ... 3998290-4 ... 4012150-0 ... 4050010-1 ... 410020-4 ... 4107340-1 ... 4116920-4 ... 4179170-3 ... 428770-3 ... 4288350-4 ... 432180-4 ... 4345560-3 ... 4366430-0 ... 440010-0 ... 4416740-7 ... 4421940-7 ... 4507560-3 ... 46470-8 ... 4651020-6 ... 4692880-4 ... 4716240-6 ... 4730250-0 ... 4732250-0 ... 4845310-2 ... 4941300-7 ... 50001080-3 ... 50002520-7 ... 50017800-3 ... 50028750-3 ... 50030670-2 ... 50032280-5 ... 50033340-8 ... 50034850-2 ... 50035860-5 ... 50036990-9 ... 50037400-7 ... 50037650-6 ... 50038920-9 ... 50047020-0 ... 50060170-4 ... 50061570-5 ... 50062160-8 ... 50066800-0 ... 50078920-7 ... 50082020-1 ... 50083320-6 ... 5025370-0 ... 5070050-2 ... 5107680-2 ... 5155780-0 ... 5183950-4 ... 5282210-9 ... 5351470-0 ... 5357880-5 ... 5365190-1 ... 539800-2 ... 545520-0 ... 5621980-6 ... 5632950-4 ... 5714430-3 ... 572080-0 ... 5751190-0 ... 579240-1 ... 579970-8 ... 6232700-3 ... 624910-8 ... 628910-0 ... 6331180-1 ... 685060-0 ... 6914900-3 ... 716120-4 ... 7167830-1 ... 717240-0 ... 786480-9 ... 80005820-8 ... 80006669-3 ... 80006750-9 ... 80011350-0 ... 80017690-1 ... 80019740-2 ... 80020720-3 ... 80022460-4 ... 80027090-8 ... 80031640-1 ... 80034800-1 ... 80034917-2 ... 80040580-3 ... 80048500-9 ... 80050224-8 ... 80051740-7 ... 80056320-4 ... 80056920-2 ... 80060240-4 ... 80060340-0 ... 80061853-0 ... 80061890-4 ... 80065130-8 ... 80065230-4 ... 80065872-8 ... 80071980-8 ... 80072700-2 ... 80075200-7 ... 80078770-6 ... 80084300-2 ... 80084780-6 ... 80086010-1 ... 80088870-7 ... 80097050-0 ... 80101690-8 ... 80102430-7 ... 881220-9 ... 891380-3 ... 897820-4 ... 929240-3 ... 964900-0 ... 989120-0 ... 992100-1 ... 998620-0 ... ... ''' >>> [x for x in numbers.splitlines() if x and not ruc.is_valid(x)] []