示例#1
0
    def test_picam_still_saves_appropriate_normal_exposure_picture_document(self, cs_save_picture):
        cs.check_if_image_is_too_dark = Mock(return_value=False)
        get_brightness_threshold = Mock(return_value=0)
        get_retake_picam_pics_when_dark_setting = Mock(return_value=False)
        cs.get_group_document = Mock(return_value={})

        Picam.take_still = Mock()
        snap_id = uuid.uuid4()
        group_id = uuid.uuid4()
        normal_exposure_pic_id = uuid.uuid4()
        long_exposure_pic_id = uuid.uuid4()

        cs.take_picam_still(snap_id, group_id, normal_exposure_pic_id, long_exposure_pic_id)

        picture_name = cs.build_picture_name(normal_exposure_pic_id)
        picture_path = cs.build_picture_path(picture_name=picture_name, snap_id=snap_id)

        cs.save_picture.assert_called_once_with(
            {'_id': str(normal_exposure_pic_id),
             'type': 'picture',
             'source': 'picam',
             'exposure_type': 'standard',
             'group_id': str(group_id),
             'snap_id': str(snap_id),
             'filename': picture_name,
             'uri': ANY,
             'created': ANY}, clean_up_files=True)
示例#2
0
    def test_picam_still_calls_picam_camera_class_as_expected_for_long_exposure(
            self):
        Picam.take_still = Mock()
        Picam.take_long_exposure_still = Mock()
        cs.check_if_image_is_too_dark = Mock(return_value=True)
        get_brightness_threshold = Mock(return_value=0)
        get_retake_picam_pics_when_dark_setting = Mock(return_value=True)
        cs.get_group_document = Mock(return_value={})

        snap_id = uuid.uuid4()
        group_id = uuid.uuid4()
        normal_exposure_pic_id = uuid.uuid4()
        long_exposure_pic_id = uuid.uuid4()

        cs.take_picam_still(snap_id, group_id, normal_exposure_pic_id,
                            long_exposure_pic_id)

        picture_name = cs.build_picture_name(long_exposure_pic_id)
        picture_path = cs.build_picture_path(picture_name=picture_name,
                                             snap_id=snap_id)
        image_width = current_app.config['STILL_IMAGE_WIDTH']
        image_height = current_app.config['STILL_IMAGE_HEIGHT']

        Picam.take_long_exposure_still.assert_called_once_with(
            pic_path=picture_path,
            image_width=image_width,
            image_height=image_height)
示例#3
0
    def test_picam_still_saves_appropriate_normal_exposure_picture_document(
            self, cs_save_picture):
        cs.check_if_image_is_too_dark = Mock(return_value=False)
        get_brightness_threshold = Mock(return_value=0)
        get_retake_picam_pics_when_dark_setting = Mock(return_value=False)
        cs.get_group_document = Mock(return_value={})

        Picam.take_still = Mock()
        snap_id = uuid.uuid4()
        group_id = uuid.uuid4()
        normal_exposure_pic_id = uuid.uuid4()
        long_exposure_pic_id = uuid.uuid4()

        cs.take_picam_still(snap_id, group_id, normal_exposure_pic_id,
                            long_exposure_pic_id)

        picture_name = cs.build_picture_name(normal_exposure_pic_id)
        picture_path = cs.build_picture_path(picture_name=picture_name,
                                             snap_id=snap_id)

        cs.save_picture.assert_called_once_with(
            {
                '_id': str(normal_exposure_pic_id),
                'type': 'picture',
                'source': 'picam',
                'exposure_type': 'standard',
                'group_id': str(group_id),
                'snap_id': str(snap_id),
                'filename': picture_name,
                'uri': ANY,
                'created': ANY
            },
            clean_up_files=True)
示例#4
0
    def test_picam_still_saves_appropriate_long_exposure_picture_document(self, cs_save_picture):
        cs.check_if_image_is_too_dark = Mock(return_value=True)
        get_brightness_threshold = Mock(return_value=0)
        cs.get_retake_picam_pics_when_dark_setting = Mock(return_value=True)
        cs.get_group_document = Mock(return_value={})

        Picam.take_still = Mock()
        Picam.take_long_exposure_still = Mock()
        snap_id = uuid.uuid4()
        group_id = uuid.uuid4()
        normal_exposure_pic_id = uuid.uuid4()
        long_exposure_pic_id = uuid.uuid4()

        cs.take_picam_still(snap_id, group_id, normal_exposure_pic_id, long_exposure_pic_id)

        long_exposure_picture_name = cs.build_picture_name(long_exposure_pic_id)
        long_exposure_picture_path = cs.build_picture_path(picture_name=long_exposure_picture_name, snap_id=snap_id)

        call_1 = call(
                      {'_id': str(normal_exposure_pic_id),
                       'type': 'picture',
                       'source': 'picam',
                       'exposure_type': 'standard',
                       'group_id': str(group_id),
                       'snap_id': ANY,
                       'filename': ANY,
                       'uri': ANY,
                       'created': ANY
                      }
                     )
        call_2 = call(
                      {'_id': str(long_exposure_pic_id),
                       'type': 'picture',
                       'source': 'picam',
                       'exposure_type': 'long',
                       'group_id': str(group_id),
                       'snap_id': str(snap_id),
                       'filename': long_exposure_picture_name,
                       'uri': ANY,
                       'created': ANY
                      }
                     )

        calls = [call_1, call_2]
        cs_save_picture.assert_has_calls(calls)
示例#5
0
    def test_picam_still_calls_picam_camera_class_as_expected_for_long_exposure(self):
        Picam.take_still = Mock()
        Picam.take_long_exposure_still = Mock()
        cs.check_if_image_is_too_dark = Mock(return_value=True)
        get_brightness_threshold = Mock(return_value=0)
        get_retake_picam_pics_when_dark_setting = Mock(return_value=True)
        cs.get_group_document = Mock(return_value={})

        snap_id = uuid.uuid4()
        group_id = uuid.uuid4()
        normal_exposure_pic_id = uuid.uuid4()
        long_exposure_pic_id = uuid.uuid4()

        cs.take_picam_still(snap_id, group_id, normal_exposure_pic_id, long_exposure_pic_id)

        picture_name = cs.build_picture_name(long_exposure_pic_id)
        picture_path = cs.build_picture_path(picture_name=picture_name, snap_id=snap_id)
        image_width = current_app.config['STILL_IMAGE_WIDTH']
        image_height = current_app.config['STILL_IMAGE_HEIGHT']

        Picam.take_long_exposure_still.assert_called_once_with(pic_path=picture_path,
                                                               image_width=image_width,
                                                               image_height=image_height)