-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
test_camera.py
51 lines (43 loc) · 1.73 KB
/
test_camera.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
import unittest
from camera import exposureCalc
class test_camera(unittest.TestCase):
def test_exposureCalc_lowerBounds(self):
exposureCalc1=exposureCalc(700,1700)
self.assertEqual(exposureCalc1.get_exposure(700), "auto")
def test_exposureCalc_upperBounds(self):
exposureCalc1=exposureCalc(700,1700)
self.assertEqual(exposureCalc1.get_exposure(1700), "auto")
def test_exposureCalc_middleBounds(self):
exposureCalc1=exposureCalc(700,1700)
self.assertEqual(exposureCalc1.get_exposure(1245), "auto")
def test_exposureCalc_outsideUpperBounds(self):
exposureCalc1=exposureCalc(700,1700)
self.assertEqual(exposureCalc1.get_exposure(2130), "night")
def test_exposureCalc_outsideLowerBounds(self):
exposureCalc1=exposureCalc(700,1700)
self.assertEqual(exposureCalc1.get_exposure(600), "night")
def test_take_shot(self):
exp=exposureCalc(700,1700)
self.assertEqual(exp.take_shot(1700), True)
self.assertEqual(exp.take_shot(1245), True)
self.assertEqual(exp.take_shot(700), True)
self.assertEqual(exp.take_shot(699), False)
self.assertEqual(exp.take_shot(0), False)
self.assertEqual(exp.take_shot(500), False)
self.assertEqual(exp.take_shot(2100), False)
def test_take_shot_rangetest(self):
exp=exposureCalc(700, 1700)
for x in range(0,2300):
val = exp.take_shot(x)
# print(str(x) + " = (x) = " + str(val))
if(x >= 700 and x <= 1700):
self.assertTrue(val)
else:
self.assertFalse(val)
def test_exposureCalc_rangetest(self):
exp=exposureCalc(700, 1700)
for x in range(0,2300):
value = exp.get_exposure(x)
self.assertTrue(value in ('auto','night'), 'value: ' + str(value) + ' not in collection')
if __name__ == '__main__':
unittest.main()