~homeworkprod/byceps

ref: 9f63b62a2b4647a97ebd3b6356d937ffa1d88876 byceps/tests/util/test_checkdigit.py -rw-r--r-- 787 bytes
9f63b62a — Jochen Kupperschmidt Note that Python 3.6 is a supported Python version 4 years ago
                                                                                
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
"""
:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from nose2.tools import params

from byceps.util.checkdigit import calculate_check_digit


@params(
    ('12',         5),
    ('123',        0),
    ('1245496594', 3),
    ('TEST',       4),
    ('Test123',    7),
    ('00012',      5),
    ('9',          1),
    ('999',        3),
    ('999999',     6),
    ('CHECKDIGIT', 7),
    ('EK8XO5V9T8', 2),
    ('Y9IDV90NVK', 1),
    ('RWRGBM8C5S', 5),
    ('OBYY3LXR79', 5),
    ('Z2N9Z3F0K3', 2),
    ('ROBL3MPLSE', 9),
    ('VQWEWFNY8U', 9),
    ('45TPECUWKJ', 1),
    ('6KWKDFD79A', 8),
    ('HXNPKGY4EX', 3),
    ('91BT',       2),
)
def test_calculate_check_digit(chars, expected):
    assert calculate_check_digit(chars) == expected