-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_unit.py
More file actions
32 lines (24 loc) · 1.09 KB
/
tests_unit.py
File metadata and controls
32 lines (24 loc) · 1.09 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
import unittest
from functions.get_files_info import get_files_info
class TestGetFiles(unittest.TestCase):
def test_1(self):
result = get_files_info("calculator", ".")
self.assertEqual(result.split('\n'), [
"- main.py: file_size=576 bytes, is_dir=False",
"- pkg: file_size=4096 bytes, is_dir=True",
"- tests.py: file_size=1343 bytes, is_dir=False"
])
def test_2(self):
result = get_files_info("calculator", "pkg")
self.assertEqual(result.split('\n'), [
"- calculator.py: file_size=1739 bytes, is_dir=False",
"- render.py: file_size=768 bytes, is_dir=False"
])
def test_3(self):
result = get_files_info("calculator", "/bin")
self.assertEqual(result, 'Error: Cannot list "/bin" as it is outside the permitted working directory')
def test_4(self):
result = get_files_info("calculator", "..")
self.assertEqual(result, 'Error: Cannot list ".." as it is outside the permitted working directory')
if __name__ == '__main__':
unittest.main()