-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
66 lines (55 loc) · 2.09 KB
/
test.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import unittest
from enum import Enum
import lsb
import numpy as np
import os.path
from PIL import Image
class TestImage(Enum):
CAT = "./sample_images/cat.png"
LICHTENSEIN = "./sample_images/lichtenstein.png"
TREES = "./sample_images/trees.png"
NOT_EXIST = "./sample_images/invalid"
class TestSum(unittest.TestCase):
def test_bitplane_analyzer_plot(self):
result = lsb.image.bitplane.analyze(TestImage.CAT.value)
assert type(result) is np.ndarray
def test_bitplane_analyzer_savefig(self):
for i in {TestImage.CAT, TestImage.LICHTENSEIN, TestImage.TREES}:
lsb.image.bitplane.analyze(i.value)
assert os.path.isfile("./output/bitplanes.png")
im = Image.open("./output/bitplanes.png")
im.verify()
def test_bitplane_analyzer_invalid_file(self):
try:
lsb.image.bitplane.analyze(TestImage.NOT_EXIST.value)
except FileNotFoundError:
return
def test_combine_bitplanes(self):
files = {"red", "green", "blue", "combined"}
for i in (True, False):
for j in (True, False):
for upper in range(0, 7):
lsb.image.bitplane.combine(
TestImage.CAT.value, 0, upper, i, j, "./output/"
)
for i in files:
assert os.path.isfile(f"./output/secret_{i}.png")
im = Image.open(f"./output/secret_{i}.png")
im.verify()
def test_combine_bitplanes_invalid_file(self):
try:
lsb.image.bitplane.analyze(TestImage.NOT_EXIST.value)
except FileNotFoundError:
return
def test_combine_bitplanes_invalid_range(self):
try:
lsb.image.bitplane.combine(TestImage.CAT.value, 0, 16, True, False, "./output/")
except IndexError:
...
try:
lsb.image.bitplane.combine(TestImage.CAT.value, 8, 6, True, False, "./output/")
except Warning:
...
print("asd")
if __name__ == "__main__":
unittest.main()