-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
80 lines (72 loc) · 3.39 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
from detection import detectImage
from PIL import Image
class TestFace(object):
def test_face(self):
image = Image.open("test_images/crosby-smile.jpg")
response = detectImage(image)
assert response['face']['emotion'] == "happy"
assert 240 <= response['face']['height'] <= 280
assert 240 <= response['face']['width'] <= 280
assert 65 <= response['face']['x'] <= 105
assert 110 <= response['face']['y'] <= 150
def test_face_one_hand(self):
image = Image.open("test_images/one-hand.jpg")
response = detectImage(image)
assert response['face']['emotion'] == "neutral"
assert 810 <= response['face']['height'] <= 850
assert 810 <= response['face']['width'] <= 850
assert 1165 <= response['face']['x'] <= 1205
assert 320 <= response['face']['y'] <= 360
def test_face_two_hands(self):
image = Image.open("test_images/two-hands.jpg")
response = detectImage(image)
assert response['face']['emotion'] == "neutral"
assert 860 <= response['face']['height'] <= 900
assert 860 <= response['face']['width'] <= 900
assert 930 <= response['face']['x'] <= 970
assert 620 <= response['face']['y'] <= 660
def test_no_face(self):
image = Image.open("test_images/pikachu.jpg")
response = detectImage(image)
assert response['face']['emotion'] == None
assert response['face']['height'] == None
assert response['face']['width'] == None
assert response['face']['x'] == None
assert response['face']['y'] == None
class TestHands(object):
def test_no_hands(self):
image = Image.open("test_images/pikachu.jpg")
response = detectImage(image)
assert len(response['hands']) == 2
assert response['hands'][0]['height'] == None
assert response['hands'][0]['width'] == None
assert response['hands'][0]['x'] == None
assert response['hands'][0]['y'] == None
assert response['hands'][1]['height'] == None
assert response['hands'][1]['width'] == None
assert response['hands'][1]['x'] == None
assert response['hands'][1]['y'] == None
def test_one_hand(self):
image = Image.open("test_images/one-hand.jpg")
response = detectImage(image)
assert len(response['hands']) == 2
assert 1140 <= response['hands'][0]['height'] <= 1180
assert 715 <= response['hands'][0]['width'] <= 755
assert 30 <= response['hands'][0]['x'] <= 70
assert 770 <= response['hands'][0]['y'] <= 810
assert response['hands'][1]['height'] == None
assert response['hands'][1]['width'] == None
assert response['hands'][1]['x'] == None
assert response['hands'][1]['y'] == None
def test_two_hands(self):
image = Image.open("test_images/two-hands.jpg")
response = detectImage(image)
assert len(response['hands']) == 2
assert 1200 <= response['hands'][0]['height'] <= 1240
assert 850 <= response['hands'][0]['width'] <= 890
assert 0 <= response['hands'][0]['x'] <= 20
assert 940 <= response['hands'][0]['y'] <= 980
assert 1230 <= response['hands'][1]['height'] <= 1270
assert 830 <= response['hands'][1]['width'] <= 870
assert 2070 <= response['hands'][1]['x'] <= 2110
assert 840 <= response['hands'][1]['y'] <= 880