Total Complexity | 9 |
Total Lines | 31 |
Duplicated Lines | 0 % |
1 | # -*- coding: utf-8 -*- |
||
11 | class TestCsvToJsonConverter(): |
||
12 | |||
13 | # def teardown_method(self, method): |
||
14 | # # teardown_method is invoked after every test method of a class |
||
15 | # self.csv_file.close() |
||
16 | |||
17 | def setup_method(self, method): |
||
18 | # setup_method is invoked befor every test method of a class |
||
19 | self.converter = csvToJsonConverter() |
||
20 | |||
21 | def test_complete_run(self): |
||
22 | result_path = "testData/test_result.json" |
||
23 | try: |
||
24 | os.remove(result_path) |
||
25 | except OSError: |
||
26 | pass |
||
27 | assert os.path.isfile(result_path) == False |
||
28 | self.converter.run("testData/test_for_jsonConverter.csv", result_path) |
||
29 | assert os.path.isfile(result_path) == True |
||
30 | with open("testData/expected_result.json", 'r') as expected_result_file: |
||
31 | expected_result = expected_result_file.read() |
||
32 | with open(result_path, 'r') as result_file: |
||
33 | result = result_file.read() |
||
34 | assert expected_result == result |
||
35 | |||
36 | def test_run(self): |
||
37 | self.converter.create_dump_list = Mock(return_value=[{"dumpListElement1"}, {"dumpListElement2"}]) |
||
38 | self.converter.write_dump_list_to_file = Mock() |
||
39 | self.converter.run("csvPath", "jsonPath") |
||
40 | self.converter.create_dump_list.assert_called_once_with("csvPath") |
||
41 | self.converter.write_dump_list_to_file.assert_called_once_with([{"dumpListElement1"}, {"dumpListElement2"}], "jsonPath") |