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

TestFileOperations   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestFileOperations.test_file_statistics() 0 5 1
A TestFileOperations.setUp() 0 7 2
A TestFileOperations.test_file_dates() 0 5 1
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