forked from WSU-4110/PyMerge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunitTesting.py
More file actions
60 lines (47 loc) · 2.5 KB
/
Copy pathunitTesting.py
File metadata and controls
60 lines (47 loc) · 2.5 KB
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
import sys
import unittest
from PyQt5.QtWidgets import QApplication
import FileIO
import MainWindow
import utilities
app = QApplication(sys.argv)
class UnitTest(unittest.TestCase):
def setUp(self):
self.mainWindow = MainWindow.MainWindow("file1.c", "file2.c")
self.fileIO = FileIO
self.util = utilities
def test_openFile(self):
self.mainWindow.open_file()
expectedFileA = "/Users/saularraffi/Documents/School Work Archive/Fall " \
"2019 Semester/Software Engineering/Lab/PyMerge/file1.c"
expectedFileB = "/Users/saularraffi/Documents/School Work Archive/Fall " \
"2019 Semester/Software Engineering/Lab/PyMerge/file2.c"
self.assertEqual(self.mainWindow.fileA, expectedFileA)
self.assertEqual(self.mainWindow.fileB, expectedFileB)
def test_valid_file_ext(self):
self.assertEqual(self.util.valid_file_ext("file1.c"), True)
self.assertEqual(self.util.valid_file_ext("file2.c"), True)
self.assertEqual(self.util.valid_file_ext("badFile.docx"), False)
def test_file_readable(self):
self.assertEqual(self.util.file_readable("file1.c"), True)
self.assertEqual(self.util.file_readable("file2.c"), True)
def test_file_writable(self):
self.assertEqual(self.util.file_writable("file1.c"), True)
self.assertEqual(self.util.file_writable("file2.c"), True)
def test_valid_file_size(self):
self.assertEqual(self.util.validate_file_size("file1.c", 1000), True)
self.assertEqual(self.util.validate_file_size("file1.c", 900), True)
self.assertEqual(self.util.validate_file_size("file1.c", 850), True)
self.assertEqual(self.util.validate_file_size("file1.c", 849), False)
def test_check_paths(self):
file1_path = "/Users/saularraffi/Documents/School Work Archive/Fall " \
"2019 Semester/Software Engineering/Lab/PyMerge/file1.c"
file2_path = "/Users/saularraffi/Documents/School Work Archive/Fall " \
"2019 Semester/Software Engineering/Lab/PyMerge/file2.c"
invalid_path = "/Users/saularraffi/Documents/School Work Archive/Fall " \
"2019 Semester/Software Engineering/Lab/PyMerge/does-not-exist.txt"
self.assertEqual(self.util.check_paths(file1_path),True)
self.assertEqual(self.util.check_paths(file2_path), True)
self.assertEqual(self.util.check_paths(invalid_path), False)
if __name__ == '__main__':
unittest.main()