forked from pycolombia/kata-01-bank-ocr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank_test.py
78 lines (57 loc) · 1.96 KB
/
bank_test.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from code_source import get_lineas, parseCuenta, \
checksum_cuenta, ERR_ILL, formatear_cuenta, fixDigit
class KataBankTest(unittest.TestCase):
"""docstring for Kata"""
def test_parse_cuenta(self):
lineas = get_lineas('resources.txt')
digitos, error = parseCuenta(lineas)
self.assertEqual(range(1, 10), digitos)
def test_checksum_cuenta(self):
digitos = [3, 4, 5, 8, 8, 2, 8, 6, 5]
self.assertTrue(checksum_cuenta(digitos))
def test_checksum_cuenta_false(self):
digitos = [1, 4, 5, 8, 8, 2, 8, 6, 5]
self.assertFalse(checksum_cuenta(digitos))
def test_parse_err(self):
lineas = get_lineas('test-data/case3/1234_678_-ILL')
digitos, error = parseCuenta(lineas)
self.assertEqual(error, ERR_ILL)
def test_report_account_parse(self):
lineas = get_lineas('test-data/case3/1234_678_-ILL')
digitos, error = parseCuenta(lineas)
s = formatear_cuenta(digitos, error)
self.assertEqual("1234?678? ILL", s)
def test_report_account_parse_ok(self):
lineas = get_lineas('test-data/case3/000000051')
digitos, error = parseCuenta(lineas)
s = formatear_cuenta(digitos, error)
self.assertEqual("000000051", s)
def test_report_account_parse_err(self):
lineas = get_lineas('test-data/case3/000000052-ERR')
digitos, error = parseCuenta(lineas)
s = formatear_cuenta(digitos, error)
self.assertEqual("000000052 ERR", s)
def test_fix_digit1(self):
m = (
(" ", " ", " "),
(" ", " ", " "),
(" ", " ", "|"))
lista_numeros = fixDigit(m)
self.assertEqual(lista_numeros, [1])
def test_fix_digit2(self):
m = (
(" ", "_", " "),
("|", "_", "|"),
("|", "_", "|"))
lista_numeros = fixDigit(m)
self.assertEqual(lista_numeros, [0,6])
def test_correction1(self):
lineas = get_lineas('test-data/case4/000000051')
digitos, error = parseCuenta(lineas)
s = formatear_cuenta(digitos, error)
self.assertEqual("000000051", s)
if __name__ == '__main__':
unittest.main()