test_co_nit.doctest - more detailed doctests for the stdnum.co.nit module Copyright (C) 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.co.nit module. >>> from stdnum.co import nit >>> from stdnum.exceptions import * Some more detailed checks. Some of these were previously in the module docstring. >>> nit.validate('213.123.432-1') '2131234321' >>> nit.validate('2131234351') '2131234351' >>> nit.validate('2131234351') '2131234351' >>> nit.validate('2131234') Traceback (most recent call last): ... InvalidLength: ... >>> nit.validate('213123435A') Traceback (most recent call last): ... InvalidFormat: ... >>> nit.validate('2131234350') Traceback (most recent call last): ... InvalidChecksum: ... Extra checks for format function to see that it works with all kinds of lengths. >>> nit.format('123.456.789-0') '123.456.789-0' >>> nit.format('12.345.678.912-0') '12.345.678.912-0' >>> nit.format('1.234.567-0') '1.234.567-0' These have been found online and should all be valid numbers. >>> numbers = ''' ... ... 1118534248-0 ... 15.252.525-0 ... 17.343.020-1 ... 35324530-0 ... 37547837-0 ... 375478370 ... 51.922.998-7 ... 52.238.803-1 ... 6.386.949-2 ... 79.308.960-7 ... 79.896.529.6 ... 79626331-8 ... 79627373-1 ... 796273731 ... 800.003.122-6 ... 800.020.672-7 ... 800.026.452-0 ... 800.043.909-6 ... 800.100.532-8 ... 800.184.048-4 ... 800.219.488-4 ... 800.231.969-4 ... 800.242.106-2 ... 800.249.704-9 ... 800088702-2 ... 800112806-2 ... 800130907-4 ... 800140949-6 ... 800216278-0 ... 800224808-8 ... 800224827-8 ... 800226098 - 4 ... 800227940-6 ... 800228175 - 2 ... 800229739-0 ... 800231967-1 ... 800231969-4 ... 800240882-0 ... 800242272-7 ... 800250119-1 ... 800251440-6 ... 800253055-2 ... 800256161 - 9 ... 804001273-5 ... 805.014.583-3 ... 805000427-1 ... 805001157-2 ... 805021984-2 ... 811.014.798-1 ... 811019263-6 ... 812.007.765-3 ... 819.006.966-8 ... 830.015.428-5 ... 830.025.281-2 ... 830.035.734-1 ... 830.036-334-1 ... 830.042.619-1 ... 830.056.202-3 ... 830.061.111-1 ... 830.096.401-3 ... 830.136.779-4 ... 830003564-7 ... 830005997 - 1 ... 830005997-1 ... 830006404-0 ... 830008686-1 ... 830009783-0 ... 830074184-5 ... 830096513-1 ... 830097607-8 ... 830113831-0 ... 830125132-2 ... 830130800-4 ... 844.003.225-6 ... 844.003.392-8 ... 860 001 986-1 ... 860.001.986-1 ... 860.002.134-8 ... 860.002.184-6 ... 860.006.606-0 ... 860.007.331-5 ... 860.007.336-1 ... 860.013.433-2 ... 860.013.570-3 ... 860.013.798-5 ... 860.020.309-6 ... 860.033.941-8 ... 860.045.904-7 ... 860.051.784-4 ... 860.065.795-6 ... 860.066.942-7 ... 860.400.538-7 ... 860.400.602-0 ... 860.402.717-8 ... 860.511.071-6 ... 860.516.636-1 ... 860.527.857-8 ... 860001986-1 ... 8600019861 ... 860002183 - 9 ... 860002183-9 ... 860002503 - 2 ... 860002503-2 ... 860002527-9 ... 860002528 - 6 ... 860002964-4 ... 860006606-0 ... 860007331-5 ... 8600073361 ... 860007379-8 ... 860009174-4 ... 860011153 - 6 ... 860011153-6 ... 860013433-2 ... 860013816 - 1 ... 860013816-1 ... 860022137-5 ... 860027404 - 1 ... 860027404-1 ... 860028415 - 5 ... 860066942-7 ... 860503617 - 3 ... 860512237-6 ... 890 981 268 -— 4 ... 890 981 268 — 4 ... 890.000.062-6 ... 890.000.381-0 ... 890.101.994-9 ... 890.102.002-2 ... 890.102.044-1 ... 890.106.291-2 ... 890.201.213-4 ... 890.201.578-7 ... 890.270.275-5 ... 890.303.093-5 ... 890.304.033-8 ... 890.399.025-6 ... 890.480.023-7 ... 890.480.110-1 ... 890.500.516-3 ... 890.500.675-6 ... 890.680.023-5 ... 890.700.148-4 ... 890.700.679-3 ... 890.806.490-5 ... 890.900.840-1 ... 890.900.841-9 ... 890.907.106-5 ... 890000062-6 ... 890000381-0 ... 890102044-1 ... 890303093-5 ... 890480110-1 ... 890680023-5 ... 890704737-0 ... 890900840-1 ... 890900842-6 ... 8909009431 ... 890904996-1 ... 891.080.005-1 ... 891.180.008-2 ... 891.190.047-2 ... 891.190.346-1 ... 891.200.208-6 ... 891.200.337-8 ... 891.380.056-4 ... 891.400.726-8 ... 891.411.166-0 ... 891.480.000-1 ... 891.480.035-9 ... 891.500.182-0 ... 891.600.091-8 ... 891.780.093-3 ... 891.800.213-8 ... 891.856.077-3 ... 891.900.280-0 ... 891.900.452-0 ... 891280008-1 ... 891380003-4 ... 891480000-1 ... 891500182-0 ... 891900280-0 ... 891900452-0 ... 892.115.006-5 ... 892.200.015-5 ... 892.399.989-8 ... 892.400.320-5 ... 899.999.035-7 ... 899999001-7 ... 899999010-3 ... 899999026-0 ... 899999034-1 ... 899999054-7 ... 899999239-2 ... 899999734-7 ... 900 206 480 - 2 ... 900 206 480-2 ... 900 206 483-4 ... 900,206,480-2 ... 900,206,483-4 ... 900.006.334-7 ... 900.018.436-1 ... 900.086.865-8 ... 900.141.702-1 ... 900.187.401-8 ... 900.206,483-4 ... 900.206.480-2 ... 900.206.483-4 ... 900.274.326-6 ... 900.311.121-2 ... 900.320.056-1 ... 900.323.466—1 ... 900.343.302-6 ... 900.433.479-7 ... 900.465.924-0 ... 900.499.432-5 ... 900074992-3 ... 900112778-7 ... 900156264-2 ... 900206480-2 ... 900206483-4 ... 900219251-9 ... 900227140-3 ... 9002271403 ... 900264507-1 ... 900299795-5 ... 900336004-7 ... 900356846-7 ... 900462447-5 ... 900812264-7 ... ... ''' >>> [x for x in numbers.splitlines() if x and not nit.is_valid(x)] []