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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
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: ...
|