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
|
test_id_npwp.doctest - more detailed doctests for stdnum.id.npwp module
Copyright (C) 2020 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.id.npwp module. It
tries to test more corner cases and detailed functionality that is not really
useful as module documentation.
>>> from stdnum.id import npwp
Tests for some corner cases.
>>> npwp.validate('023869720091000')
'023869720091000'
>>> npwp.validate('01.451.869.0-054.000')
'014518690054000'
>>> npwp.validate('02 . 433 . 917 . 8 - 011 . 000')
'024339178011000'
>>> npwp.format('013319595054000')
'01.331.959.5-054.000'
>>> npwp.validate('12345678901234')
Traceback (most recent call last):
...
InvalidLength: ...
>>> npwp.validate('FF3456789012345')
Traceback (most recent call last):
...
InvalidFormat: ...
>>> npwp.validate('01.451.869.7-054.000')
Traceback (most recent call last):
...
InvalidChecksum: ...
These have been found online and should all be valid numbers.
>>> numbers = '''
...
... 01.001.610.3-051.000
... 01.001.634.3-093.000
... 01.105.197.6-424.000
... 01.112.397.3-441.000
... 01.125.612.0-805.000
... 01.129.154.9-201.000
... 01.216.271.5-441.000
... 01.258.022.1-201.000
... 01.268.426.2-201.000
... 01.311.830.2-073.000
... 01.318.451.0-054.000
... 01.334.427.0-054.000
... 01.347.428.3-018.000
... 01.360.902.9-054.000
... 01.436.246.1-441.000
... 01.452.340.1-101.000
... 01.455.616.1-441.000
... 01.457.751.4-426.000
... 01.464.753.1-542.000
... 01.482.738.0-424.000
... 01.504.513.1-054.000
... 01.546.704.6-012.000
... 01.546.836.6-013.000
... 01.548.436.3-423.000
... 01.555.547.7-429.000
... 01.562.420.8-805.000
... 01.575.888.1-101.000
... 01.580.769.6-201.000
... 01.627.251.0-404.000
... 01.657.878.3-101.000
... 01.671.242.4-054.000
... 01.677.930.8-429.000
... 01.690.679.4-801.000
... 01.709.626.4-054.000
... 01.721.123.6-054.000
... 01.773.770.1-805.000
... 01.796.259.8-805.000
... 01.815.656.2-807.000
... 01.931.919.3-101.000
... 01.966.099.2-801.000
... 01.997.870.9-038.000
... 010692903641000
... 017048299643001
... 02.037.103.5-502.000
... 02.071.326.9-101.000
... 02.071.363.2-101.000
... 02.081.228.5-424.000
... 02.098.700.4-013.000
... 02.098.788.9-013.000
... 02.102.011.0-101.000
... 02.151.039.1-106.000
... 02.173.740.8-002.000
... 02.203.654.5-429.000
... 02.333.122.6-441.000
... 02.367.986.3-426.000
... 02.399.244.9-091.000
... 02.446.000.8-429.000
... 02.480.884.2-444.000
... 02.504.191.4-054.000
... 02.527.123.0-017.000
... 02.547.885.0-805.000
... 02.564.234.9-421.000
... 02.585.033.0-216.000
... 02.643.101.5-805.000
... 02.650.677.4-101.000
... 02.679.257.2-801.000
... 02.719.242.6-106.000
... 02.755.249.6-541.000
... 02.790.820.1-428.000
... 02.887.783.5-105.000
... 02.910.648.1-805.000
... 02.932.094.2-101.000
... 02.956.222.0-106.000
... 02.956.223.8-106.000
... 02.972.041.4-428.000
... 02.976.331.5-103.000
... 02.984.042.8-201.000
... 03.026.787.6-805.000
... 03.195.088.4-801.000
... 03.217.024.3-805.000
... 21.078.367.6-424.000
... 31.294.519.9-424.000
... 31.470.209.3-428.000
... 31.496.676.3-106.000
... 31.578.913.1-201.000
... 31.682.116.4-201.000
... 31.696.264.6-201.000
... 31.729.429.6-542.000
... 66.487.591.1-071.000
... 70.838.297.3-201.000
... 71.269.216.9-203.000
... 75.193.535.4-805.000
... 755023033513000
... 762278075077000
... 764038907023000
... 811145994124000
... 813195435017000
... 83.132.665.7-201.000
... 84.054.217.9-609.000
... 846150324629000
... 90.004.581.6-201.000
...
... '''
>>> [x for x in numbers.splitlines() if x and not npwp.is_valid(x)]
[]
|