forked from stephengrice/onenote-to-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDateDigitsSubstitutionFactory.py
65 lines (58 loc) · 2.4 KB
/
TestDateDigitsSubstitutionFactory.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
import unittest
from path_scrubbing.DateDigitsSubstitutionFactory import DateDigitsSubstitutionFactory
class TestDateDigitsSubstitutionFactory(unittest.TestCase):
param_list = [
{
"old_sep": '/',
"new_sep": '-',
"abbrev_year": False,
"input_date_component_order": 'mdy',
"input_path_component": '01/02/2023',
"output_date_component_order": 'ymd',
"expected": '2023-01-02',
},
{
"old_sep": '_',
"new_sep": '-',
"abbrev_year": False,
"input_date_component_order": 'mdy',
"input_path_component": '01_02_2023',
"output_date_component_order": 'ymd',
"expected": '2023-01-02',
},
{
"old_sep": '-',
"new_sep": '-',
"abbrev_year": False,
"input_date_component_order": 'ymd',
"input_path_component": '2017-7-11',
"output_date_component_order": 'ymd',
"expected": '2017-07-11',
},
{
"old_sep": '/',
"new_sep": '-',
"abbrev_year": False,
"input_date_component_order": 'mdy',
"input_path_component": '7/11/2017',
"output_date_component_order": 'ymd',
"expected": '2017-07-11',
},
]
def test_given_params_can_create_substitutor_which_returns_expected(self):
for param_set in self.param_list:
with self.subTest(**param_set):
# Arrange
old_sep = param_set['old_sep']
new_sep = param_set['new_sep']
abbrev_year = param_set['abbrev_year']
input_date_component_order = param_set['input_date_component_order']
input_path_component = param_set['input_path_component']
output_date_component_order = param_set['output_date_component_order']
expected = param_set['expected']
subject = DateDigitsSubstitutionFactory(old_sep, date_component_order=input_date_component_order, abbrev_year=abbrev_year)
substitutor = subject.create_substitutor(new_date_components_sep=new_sep, new_date_component_order=output_date_component_order)
# Act
actual = substitutor(input_path_component)
# Assert
self.assertEqual(expected, actual)