Total Complexity | 4 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from datetime import datetime |
||
2 | import os |
||
3 | from db_extractor.FileOperations import FileOperations |
||
4 | import unittest |
||
5 | # package to facilitate multiple operation system operations |
||
6 | import platform |
||
7 | |||
8 | |||
9 | class TestFileOperations(unittest.TestCase): |
||
10 | |||
11 | def setUp(self) -> None: |
||
12 | python_binary = 'python' |
||
13 | if platform.system() == 'Windows': |
||
14 | python_binary += '.exe' |
||
15 | os.system(python_binary + ' ' |
||
16 | + os.path.join(os.path.normpath(os.path.dirname(__file__)) |
||
17 | .replace('test', 'sources'), 'localizations_compile.py')) |
||
18 | |||
19 | def test_file_statistics(self): |
||
20 | class_fo = FileOperations() |
||
21 | value_to_assert = class_fo.fn_get_file_statistics(__file__)['size [bytes]'] |
||
22 | value_to_compare_with = os.path.getsize(__file__) |
||
23 | self.assertEqual(value_to_assert, value_to_compare_with) |
||
24 | |||
25 | def test_file_dates(self): |
||
26 | class_fo = FileOperations() |
||
27 | value_to_assert = class_fo.fn_get_file_dates(__file__)['created'] |
||
28 | value_to_compare_with = datetime.fromtimestamp(os.path.getctime(__file__)) |
||
29 | self.assertEqual(value_to_assert, value_to_compare_with) |
||
30 |