|
| 1 | +test_be_bis.doctest - more detailed doctests for stdnum.be.bis module |
| 2 | + |
| 3 | +Copyright (C) 2023 Jeff Horemans |
| 4 | + |
| 5 | +This library is free software; you can redistribute it and/or |
| 6 | +modify it under the terms of the GNU Lesser General Public |
| 7 | +License as published by the Free Software Foundation; either |
| 8 | +version 2.1 of the License, or (at your option) any later version. |
| 9 | + |
| 10 | +This library is distributed in the hope that it will be useful, |
| 11 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | +Lesser General Public License for more details. |
| 14 | + |
| 15 | +You should have received a copy of the GNU Lesser General Public |
| 16 | +License along with this library; if not, write to the Free Software |
| 17 | +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 18 | +02110-1301 USA |
| 19 | + |
| 20 | + |
| 21 | +This file contains more detailed doctests for the stdnum.be.bis module. It |
| 22 | +tries to test more corner cases and detailed functionality that is not |
| 23 | +really useful as module documentation. |
| 24 | + |
| 25 | +>>> from stdnum.be import bis |
| 26 | + |
| 27 | + |
| 28 | +Extra tests for getting birth date, year and/or month |
| 29 | + |
| 30 | + |
| 31 | +>>> bis.get_birth_date('75.46.08-980.95') |
| 32 | +datetime.date(1975, 6, 8) |
| 33 | +>>> bis.get_birth_year('75.46.08-980.95') |
| 34 | +1975 |
| 35 | +>>> bis.get_birth_month('75.46.08-980.95') |
| 36 | +6 |
| 37 | +>>> bis.get_birth_date('01 49 07 001 85') |
| 38 | +datetime.date(2001, 9, 7) |
| 39 | +>>> bis.get_birth_year('01 49 07 001 85') |
| 40 | +2001 |
| 41 | +>>> bis.get_birth_month('01 49 07 001 85') |
| 42 | +9 |
| 43 | +>>> bis.get_birth_date('12345678901') |
| 44 | +Traceback (most recent call last): |
| 45 | + ... |
| 46 | +InvalidChecksum: ... |
| 47 | +>>> bis.get_birth_year('12345678901') |
| 48 | +Traceback (most recent call last): |
| 49 | + ... |
| 50 | +InvalidChecksum: ... |
| 51 | +>>> bis.get_birth_month('12345678901') |
| 52 | +Traceback (most recent call last): |
| 53 | + ... |
| 54 | +InvalidChecksum: ... |
| 55 | +>>> bis.get_birth_date('00400100155') # Exact date of birth unknown (fictitious date case 1900-00-01) |
| 56 | +>>> bis.get_birth_year('00400100155') |
| 57 | +>>> bis.get_birth_month('00400100155') |
| 58 | +>>> bis.get_birth_date('00200100112') # Birth date and gender unknown |
| 59 | +>>> bis.get_birth_year('00200100112') |
| 60 | +>>> bis.get_birth_month('00200100112') |
| 61 | +>>> bis.get_birth_date('00400100184') # Exact date of birth unknown (fictitious date case 2000-00-01) |
| 62 | +>>> bis.get_birth_year('00400100184') |
| 63 | +>>> bis.get_birth_month('00400100184') |
| 64 | +>>> bis.get_birth_date('00200100141') # Birth date and gender unknown |
| 65 | +>>> bis.get_birth_year('00200100141') |
| 66 | +>>> bis.get_birth_month('00200100141') |
| 67 | +>>> bis.get_birth_date('00400000117') # Only birth year known (2000-00-00) |
| 68 | +>>> bis.get_birth_year('00400000117') |
| 69 | +2000 |
| 70 | +>>> bis.get_birth_month('00400000117') |
| 71 | +>>> bis.get_birth_date('00200000171') # Only birth year known and gender unknown |
| 72 | +>>> bis.get_birth_year('00200000171') |
| 73 | +2000 |
| 74 | +>>> bis.get_birth_month('00200000171') |
| 75 | +>>> bis.get_birth_date('00410000124') # Only birth year and month known (2000-01-00) |
| 76 | +>>> bis.get_birth_year('00410000124') |
| 77 | +2000 |
| 78 | +>>> bis.get_birth_month('00410000124') |
| 79 | +1 |
| 80 | +>>> bis.get_birth_date('00210000178') # Only birth year and month known (2000-01-00) and gender unknown |
| 81 | +>>> bis.get_birth_year('00210000178') |
| 82 | +2000 |
| 83 | +>>> bis.get_birth_month('00210000178') |
| 84 | +1 |
| 85 | +>>> bis.get_birth_date('85473500193') # Unknown day of birth date (35) |
| 86 | +>>> bis.get_birth_year('85473500193') |
| 87 | +1985 |
| 88 | +>>> bis.get_birth_month('85473500193') |
| 89 | +7 |
| 90 | +>>> bis.get_birth_date('85273500150') # Unknown day of birth date (35) and gender unknown |
| 91 | +>>> bis.get_birth_year('85273500150') |
| 92 | +1985 |
| 93 | +>>> bis.get_birth_month('85273500150') |
| 94 | +7 |
| 95 | +>>> bis.get_birth_date('85533000191') # Invalid month (13) |
| 96 | +Traceback (most recent call last): |
| 97 | + ... |
| 98 | +InvalidComponent: ... |
| 99 | +>>> bis.get_birth_year('85533000191') |
| 100 | +Traceback (most recent call last): |
| 101 | + ... |
| 102 | +InvalidComponent: ... |
| 103 | +>>> bis.get_birth_month('85533000191') |
| 104 | +Traceback (most recent call last): |
| 105 | + ... |
| 106 | +InvalidComponent: ... |
| 107 | +>>> bis.get_birth_date('85333000148') |
| 108 | +Traceback (most recent call last): |
| 109 | + ... |
| 110 | +InvalidComponent: ... |
| 111 | +>>> bis.get_birth_year('85333000148') |
| 112 | +Traceback (most recent call last): |
| 113 | + ... |
| 114 | +InvalidComponent: ... |
| 115 | +>>> bis.get_birth_month('85333000148') |
| 116 | +Traceback (most recent call last): |
| 117 | + ... |
| 118 | +InvalidComponent: ... |
| 119 | + |
| 120 | + |
| 121 | +Extra tests for getting gender. |
| 122 | + |
| 123 | +>>> bis.get_gender('75.46.08-980.95') |
| 124 | +'F' |
| 125 | +>>> bis.get_gender('75.26.08-980.52') # Gender unknown (month incremented by 20) |
| 126 | +>>> bis.get_gender('85473500193') |
| 127 | +'M' |
| 128 | +>>> bis.get_gender('85273500150') |
| 129 | + |
| 130 | + |
| 131 | +A NN should not be considered a valid BIS number. |
| 132 | + |
| 133 | +>>> bis.validate('00000100195') |
| 134 | +Traceback (most recent call last): |
| 135 | + ... |
| 136 | +InvalidComponent: ... |
0 commit comments