-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
49 lines (38 loc) · 1.53 KB
/
test.py
File metadata and controls
49 lines (38 loc) · 1.53 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
import unittest
import os.path
import imghdr
from PIL import Image
import imageManipulation
class TestMethods(unittest.TestCase):
def test_test_file_exists(self):
self.assertTrue(os.path.isfile("C:\\test.png"))
def test_test_file_is_image(self):
self.assertNotEqual(imghdr.what("C:\\test.png"), None)
def test_diallow_non_images(self):
fpath = "C:\\test.txt"
#Check from main.py
if imghdr.what(fpath) is not None:
im = Image.open(fpath)
width = 500
height = 500
imageManipulation.resizeImage(im, width, height, True)
def test_create(self):
im = Image.open("C:\\test.png")
filtr = "Nearest Neighbour"
self.width = 500
self.height = 500
self.im2path = imageManipulation.resizeImage(im, filtr, self.width, self.height, True)
self.assertIsNotNone(self.im2path)
def test_created_file_exists(self):
self.assertTrue(os.path.isfile("Nearest Neighbour.png"))
def test_created_file_is_image(self):
self.assertNotEqual(imghdr.what("Nearest Neighbour.png"), None)
def test_resized_dimensions_correct(self):
im2 = Image.open("Nearest Neighbour.png")
self.width = 500
self.height = 500
newWidth, newHeight = im2.size
self.assertEqual(self.height, newHeight)
self.assertEqual(self.width, newWidth)
if __name__ == '__main__':
unittest.main()