-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcamera_test.py
More file actions
executable file
·43 lines (37 loc) · 1.26 KB
/
camera_test.py
File metadata and controls
executable file
·43 lines (37 loc) · 1.26 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
import unittest
import time
import os
import picamera_mock
import picamera
import camera
import config
class CameraTest(unittest.TestCase):
def setUp(self):
config.Config.read()
picamera.PiCamera = picamera_mock.PiCameraMock
self.cam = camera.Camera.get_instance()
def tearDown(self):
self.cam.exit()
camera.Camera._instance = None
def test_take_picture_jpeg(self):
pic = self.cam.get_image_jpeg()
self.assertTrue(pic is not None)
def test_take_picture_bgr(self):
pic = self.cam.get_image()
self.assertTrue(pic is not None)
def test_video_rec(self):
video_filename = "video_test"
self.cam.video_rec(video_filename)
time.sleep(5)
self.cam.video_stop()
v = open("data/media/VID" + video_filename + ".mp4")
t = open("data/media/VID" + video_filename + "_thumb.jpg")
self.assertTrue(v is not None and t is not None)
v.close()
t.close()
os.remove("data/media/VID" + video_filename + ".mp4")
os.remove("data/media/VID" + video_filename + "_thumb.jpg")
def test_find_color(self):
color = 'ff0000'
dist, angle = self.cam.find_color(color)
self.assertTrue(dist > 0 and angle < 180)