1
|
|
|
# pyre-strict |
|
|
|
|
2
|
|
|
|
3
|
|
|
import unittest |
4
|
|
|
from typing import List, Dict |
5
|
|
|
from paytext import PaymentText |
6
|
|
|
|
7
|
|
|
EXAMPLE_TEXTS: List[Dict[str, str]] = [ |
8
|
|
|
{ |
9
|
|
|
'input': '', |
10
|
|
|
'expected_output': '', |
11
|
|
|
}, |
12
|
|
|
{ |
13
|
|
|
'input': 'COINBASE UK, LTD EUR 15,94', |
14
|
|
|
'expected_output': 'COINBASE UK, LTD', |
15
|
|
|
}, |
16
|
|
|
{ |
17
|
|
|
'input': 'COINBASE UK, LTD EUR 182,12', |
18
|
|
|
'expected_output': 'COINBASE UK, LTD', |
19
|
|
|
}, |
20
|
|
|
{ |
21
|
|
|
'input': 'Fra: Solan Gundersen 18.06.18', |
22
|
|
|
'expected_output': 'Fra: Solan Gundersen', |
23
|
|
|
}, |
24
|
|
|
{ |
25
|
|
|
'input': '*4274 25.06 NOK 4101.00 WWW.TICKET.NO Kurs: 1.0000', |
26
|
|
|
'expected_output': 'WWW.TICKET.NO', |
27
|
|
|
}, |
28
|
|
|
{ |
29
|
|
|
'input': 'OBOS FACTORING', |
30
|
|
|
'expected_output': 'OBOS FACTORING', |
31
|
|
|
}, |
32
|
|
|
{ |
33
|
|
|
'input': '30.06 COOP PRIX VG-HU AKERSGT 55 OSLO', |
34
|
|
|
'expected_output': 'COOP PRIX VG-HU AKERSGT 55 OSLO', |
35
|
|
|
}, |
36
|
|
|
{ |
37
|
|
|
'input': '*8877 01.07 USD 12.99 IRRADIATED SOFTWARE Kurs: 8.3718', |
38
|
|
|
'expected_output': 'IRRADIATED SOFTWARE', |
39
|
|
|
}, |
40
|
|
|
{ |
41
|
|
|
'input': '*3951 01.07 EUR 4.00 GOOGLE *SVCSAPPS_hoise Kurs: 9.7250', |
42
|
|
|
'expected_output': 'GOOGLE *SVCSAPPS_hoise', |
43
|
|
|
}, |
44
|
|
|
{ |
45
|
|
|
'input': '*9090 29.06 USD 1.00 SAM HARRIS MEDIA INC Kurs: 8.3700', |
46
|
|
|
'expected_output': 'SAM HARRIS MEDIA INC', |
47
|
|
|
}, |
48
|
|
|
{ |
49
|
|
|
'input': '05.07 KIWI 471 BISLET THERESESGT 3 OSLO', |
50
|
|
|
'expected_output': 'KIWI 471 BISLET THERESESGT 3 OSLO', |
51
|
|
|
}, |
52
|
|
|
{ |
53
|
|
|
'input': '04.07 DEN NORSKE TURISTFOR. OSLO', |
54
|
|
|
'expected_output': 'DEN NORSKE TURISTFOR. OSLO', |
55
|
|
|
}, |
56
|
|
|
{ |
57
|
|
|
'input': 'Nettgiro til: Universitetet i Betalt: 05.07.18', |
58
|
|
|
'expected_output': 'Nettgiro til: Universitetet i', |
59
|
|
|
}, |
60
|
|
|
{ |
61
|
|
|
'input': '05.07 REMA SANNERGATA SANNERGATA 3 OSLO', |
62
|
|
|
'expected_output': 'REMA SANNERGATA SANNERGATA 3 OSLO', |
63
|
|
|
}, |
64
|
|
|
{ |
65
|
|
|
'input': 'Vipps', |
66
|
|
|
'expected_output': 'Vipps', |
67
|
|
|
}, |
68
|
|
|
{ |
69
|
|
|
'input': '04.07 SKOM.DAGESTAD JOSEFINEGT. OSLO', |
70
|
|
|
'expected_output': 'SKOM.DAGESTAD JOSEFINEGT. OSLO', |
71
|
|
|
}, |
72
|
|
|
{ |
73
|
|
|
'input': '*4321 29.06 USD 50.00 ITUNES.COM/BILL Rate: 1.0000', |
74
|
|
|
'expected_output': 'ITUNES.COM/BILL', |
75
|
|
|
}, |
76
|
|
|
{ |
77
|
|
|
'input': '*1234 01.07 NOK 215.00 ITUNES.COM/BILL Kurs: 1.0000', |
78
|
|
|
'expected_output': 'ITUNES.COM/BILL', |
79
|
|
|
}, |
80
|
|
|
] |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
class PaymentTextTest(unittest.TestCase): |
|
|
|
|
84
|
|
|
def test_clean(self) -> None: |
|
|
|
|
85
|
|
|
for example_text in EXAMPLE_TEXTS: |
86
|
|
|
text = PaymentText(example_text['input']) |
87
|
|
|
|
88
|
|
|
text.clean() |
89
|
|
|
|
90
|
|
|
self.assertEqual( |
91
|
|
|
str(text), |
92
|
|
|
example_text['expected_output'], |
93
|
|
|
) |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
if __name__ == '__main__': |
97
|
|
|
unittest.main() |
98
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.