test_ec_ruc.doctest - more detailed doctests for stdnum.ec.ruc module Copyright (C) 2014 Jonathan Finlay Copyright (C) 2014-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.ec.ruc. It tries to cover more corner cases and detailed functionality that is not really useful as module documentation. >>> from stdnum.ec import ruc >>> from stdnum.exceptions import * Normal natural RUC values (third digit less than 6) that should just work. >>> numbers = ''' ... 0101016905001 ... 0602910945001 ... 0910005917001 ... 0926687856001 ... 1001152287001 ... 1102755442001 ... 1104552037001 ... 1311919078001 ... 1700672486001 ... 1702264233001 ... 1704159860001 ... 1710034065001 ... 1710585264001 ... 1710589373001 ... 1713238234001 ... 1714307103001 ... 1721788659001 ... 1803557964001 ... ''' >>> [x for x in numbers.splitlines() if x and not ruc.is_valid(x)] [] Normal public RUC values (third digit is 6) that should just work. >>> numbers = ''' ... 0160000510001 ... 0160001910001 ... 0160002210001 ... 0160037780001 ... 0260000250001 ... 0260000330001 ... 0260000760001 ... 0260001060001 ... 0260001140001 ... 0360000230001 ... 0360000580001 ... 0360001040001 ... 0360016230001 ... 0360023950001 ... 0460000130001 ... 0460000210001 ... 0460000560001 ... 0460000640001 ... 0460000720001 ... 0460001020001 ... 0460014860001 ... 0460020670001 ... 0460022020001 ... 0460022100001 ... 0460022370001 ... 0460023930001 ... 0460024310001 ... 0460024660001 ... 0460024740001 ... 0460026010001 ... 0460027250001 ... 0560000380001 ... 0560000540001 ... 0560000700001 ... 0660000280001 ... 0660000520001 ... 0660000600001 ... 0660000790001 ... 0660000870001 ... 0660000950001 ... 0660001090001 ... 0660001680001 ... 0660820400001 ... 0660828140001 ... 0660831360001 ... 0760000180001 ... 0760000260001 ... 0760000340001 ... 0760000850001 ... 0760000930001 ... 0760001070001 ... 0760001150001 ... 0760001230001 ... 0760001310001 ... 0760001900001 ... 0760033270001 ... 0860000160001 ... 0860000240001 ... 0860013300001 ... 0860014460001 ... 0860017480001 ... 0860019260001 ... 0860019500001 ... 0860032440001 ... 0960000490001 ... 0960000730001 ... 0960001700001 ... 0960005290001 ... 0960006420001 ... 0968529830001 ... 0968566440001 ... 1060000180001 ... 1060000260001 ... 1060000340001 ... 1060000420001 ... 1060000500001 ... 1060000690001 ... 1060000770001 ... 1060008080001 ... 1060014480001 ... 1060016930001 ... 1060018040001 ... 1060019520001 ... 1060021420001 ... 1060024600001 ... 1160000670001 ... 1160000750001 ... 1160001130001 ... 1160001480001 ... 1160008140001 ... 1160028840001 ... 1160037400001 ... 1160039880001 ... 1160836120001 ... 1260000140001 ... 1260000220001 ... 1260000300001 ... 1260000490001 ... 1260000730001 ... 1260001700001 ... 1260001890001 ... 1260002000001 ... 1260002190001 ... 1260006340001 ... 1260006770001 ... 1260033820001 ... 1360000200001 ... 1360000390001 ... 1360000470001 ... 1360000630001 ... 1360000710001 ... 1360001520001 ... 1360001600001 ... 1360001790001 ... 1360001870001 ... 1360002840001 ... 1360003300001 ... 1360014850001 ... 1360024570001 ... 1360029100001 ... 1360047940001 ... 1360052350001 ... 1360052430001 ... 1360055100001 ... 1360059280001 ... 1460000290001 ... 1460000370001 ... 1560000780001 ... 1560001160001 ... 1560001240001 ... 1660000680001 ... 1660011020001 ... 1660012930001 ... 1760000150001 ... 1760001040001 ... 1760001550001 ... 1760003920001 ... 1760004060001 ... 1760004650001 ... 1760009880001 ... 1760013560001 ... 1768007390001 ... 1768022510001 ... 1768034600001 ... 1768045130001 ... 1768048820001 ... 1768085430001 ... 1768102970001 ... 1768119510001 ... 1768123380001 ... 1768133340001 ... 1768152130001 ... 1768153450001 ... 1768155660001 ... 1860000130001 ... 1860000210001 ... 1860000480001 ... 1860000720001 ... 1860000800001 ... 1860000990001 ... 1860001020001 ... 1860001100001 ... 1865011360001 ... 1960001190001 ... 2060000150001 ... 2060000230001 ... 2160000480001 ... 2160011760001 ... ''' >>> [x for x in numbers.splitlines() if x and not ruc.is_valid(x)] [] Normal juridical RUC values (third digit is 9) that should just work. >>> numbers = ''' ... 0190115798001 ... 0190155722001 ... 0290001269001 ... 0290003288001 ... 0390027923001 ... 0490001883001 ... 0490002669001 ... 0590041920001 ... 0590052000001 ... 0690045389001 ... 0790015002001 ... 0790024656001 ... 0990138850001 ... 0990247536001 ... 0990459444001 ... 0991189432001 ... 0991208291001 ... 0991445854001 ... 0992397535001 ... 0992563834001 ... 1090033456001 ... 1090109487001 ... 1190015110001 ... 1190068389001 ... 1390001920001 ... 1390007791001 ... 1390013678001 ... 1390089410001 ... 1390091474001 ... 1690012606001 ... 1790011674001 ... 1790023508001 ... 1790045668001 ... 1790085783001 ... 1790093204001 ... 1790325083001 ... 1790451801001 ... 1790501469001 ... 1790517454001 ... 1790567699001 ... 1790834670001 ... 1791240448001 ... 1791280156001 ... 1791280172001 ... 1791708040001 ... 1791714350001 ... 1791891465001 ... 1791942167001 ... 1792060346001 ... 1792079411001 ... 1792141869001 ... 1792147638001 ... 1792373255001 ... 1890001323001 ... 1890003628001 ... 1890037646001 ... ''' >>> [x for x in numbers.splitlines() if x and not ruc.is_valid(x)] [] Values that are invalid in one way or another: >>> ruc.validate('179206034601') # too short Traceback (most recent call last): ... InvalidLength: ... >>> ruc.validate('17920603A6001') # contains a character Traceback (most recent call last): ... InvalidFormat: ... >>> ruc.validate('0170000610001') # third digit invalid Traceback (most recent call last): ... InvalidComponent: ... >>> ruc.validate('1763154690001') # invalid check digit in natural RUC Traceback (most recent call last): ... InvalidChecksum: ... >>> ruc.validate('0160000610001') # invalid check digit in public RUC Traceback (most recent call last): ... InvalidChecksum: ... >>> ruc.validate('0190115799001') # invalid check digit in juridical RUC Traceback (most recent call last): ... InvalidChecksum: ... >>> ruc.validate('8810034069001') # invalid province code in natural RUC Traceback (most recent call last): ... InvalidComponent: ... >>> ruc.validate('8868152120001') # invalid province code in public RUC Traceback (most recent call last): ... InvalidComponent: ... >>> ruc.validate('8892397539001') # invalid province code in juridical RUC Traceback (most recent call last): ... InvalidComponent: ... >>> ruc.validate('0926687856000') # invalid establishment in natural RUC Traceback (most recent call last): ... InvalidComponent: ... >>> ruc.validate('1760001550000') # invalid establishment in public RUC Traceback (most recent call last): ... InvalidComponent: ... >>> ruc.validate('0992397535000') # invalid establishment in juridical RUC Traceback (most recent call last): ... InvalidComponent: ...