-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
40 lines (32 loc) · 1.24 KB
/
tests.py
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
import unittest
from utils.helpers import is_valid_filename, is_supported_filetype
# Helpers
class TestHelpers(unittest.TestCase):
def test_valid_filenames(self):
values = ["test.docx", "test.pdf", "test.jpg", "test.png", "/tests/test.docx"]
for value in values:
result = is_valid_filename(value)
self.assertTrue(result, f"Expected {value} to be True")
def test_invalid_filenames(self):
values = [
"test.py",
"test.js",
"test.asdfl",
"",
"12315",
]
for value in values:
result = is_valid_filename(value)
self.assertFalse(result, f"Expected {value} to be False")
def test_supported_extensions(self):
values = ["test.docx", "test.pdf", "test.jpg", "test.png"]
for value in values:
result = is_supported_filetype(value)
self.assertTrue(result, f"Expected {value} to be True")
def test_unsupported_extensions(self):
values = ["test.doc", "test.gif", "test.avi"]
for value in values:
result = is_supported_filetype(value)
self.assertFalse(result, f"Expected {value} to be False")
if __name__ == "__main__":
unittest.main()