Passed
Branch master (074b4c)
by Daniel
01:12
created

TestFileOperations.TestFileOperations.setUp()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 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