-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_imco.py
51 lines (35 loc) · 1.47 KB
/
test_imco.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
41
42
43
44
45
46
47
48
49
50
51
from imco import validate_file, validate_path, results, get_all_files_from_folder, is_folder_empty
import pytest
import os
def test_validate_file():
assert validate_file("bild.jpg") == True
assert validate_file("bild..jpg") == False
assert validate_file("bi.ld.jpg") == False
assert validate_file("bil,d.jpg") == False
assert validate_file("bild.jpgl") == False
assert validate_file("bild.jpg.webp") == False
def test_validate_path():
assert validate_path("test") == False
assert validate_path("../test") == False
assert validate_path("../test/") == True
assert validate_path("./test/") == True
assert validate_path("../te,st/") == False
assert validate_path("../test.jpg/") == False
assert validate_path("../_jpg/") == True
def test_results():
assert results("Hello", "World") == "\nHello\n\nWorld\n"
def test_results_TypeError():
with pytest.raises(TypeError):
results("hello")
def test_get_all_files_from_folder_SystemExit():
with pytest.raises(SystemExit):
get_all_files_from_folder("./unknown_folder", "webp")
def test_get_all_files_from_folder():
if not os.path.isdir("test/"):
os.mkdir("test/")
assert get_all_files_from_folder("test/", "webp") == []
def test_is_folder_empty():
assert is_folder_empty(['bild1.jpg', 'bild2.jpg'], "jpg", "./folder/") == True
def test_is_folder_empty_SystemExit():
with pytest.raises(SystemExit):
is_folder_empty([], "jpg", "./folder/")