Example #1
0
 def test_read_should_raise_exception_when_camera_not_started(
         self, mock_VideoCapture):
     camera = Camera()
     expected_image = Mock()
     expected_image.shape = (10, 20, 3)
     camera = Camera()
     mock_video_capture = mock_VideoCapture.return_value
     mock_video_capture.read.return_value = (True, expected_image)
     with self.assertRaises(Exception):
         camera.read()
Example #2
0
    def test_read_should_return_image_when_camera_running(
            self, mock_VideoCapture):
        expected_image = Mock()
        expected_image.shape = (10, 20, 3)
        camera = Camera()
        mock_video_capture = mock_VideoCapture.return_value
        mock_video_capture.read.return_value = (True, expected_image)

        camera.start()
        actual_image = camera.read()
        camera.stop()

        self.assertEqual(expected_image, actual_image)