Beispiel #1
0
 def test_picam_still_calls_all_chained_tasks(self, cs_take_picam_still, as_clean_up_files, as_send_mail):
     snap_id = uuid.uuid4()
     group_id = get_group_document('current')['_id']
     ct.take_picam_still(snap_id=snap_id, group_id=group_id, delay=0, repeat=0)
     cs_take_picam_still.assert_called_once_with(snap_id, group_id, ANY, ANY)
     as_clean_up_files.assert_called_once_with(snap_id, group_id)
     as_send_mail.assert_called_once_with(snap_id, group_id)
Beispiel #2
0
 def test_picam_still_calls_all_chained_tasks_multiple_times_when_repeat_specified(self,
                                                                                   cs_take_picam_still,
                                                                                   as_clean_up_files,
                                                                                   as_send_mail):
     snap_id = uuid.uuid4()
     group_id = get_group_document('current')['_id']
     ct.take_picam_still(snap_id=snap_id, group_id=group_id, delay=0, repeat=2)
     tps_calls = [call(snap_id, group_id, ANY, ANY), call(ANY, group_id, ANY, ANY), call(ANY, group_id, ANY, ANY)]
     ascuf_calls = [call(snap_id, group_id), call(ANY, group_id), call(ANY, group_id)]
     assm_calls = [call(snap_id, group_id), call(ANY, group_id), call(ANY, group_id)]
     cs_take_picam_still.assert_has_calls(tps_calls)
     as_clean_up_files.assert_has_calls(ascuf_calls)
     as_send_mail.assert_has_calls(assm_calls)
Beispiel #3
0
    def test_take_picam_still_calls_expected_methods_with_nonzero_repeat(self):
        camera.services.take_picam_still = Mock()
        admin.services.send_mail = Mock()
        admin.services.upload_files_to_s3 = Mock()
        admin.services.clean_up_files = Mock()

        return_value = ct.take_picam_still('some_snap_id',
                                           'some_group_id',
                                           delay=0,
                                           repeat=2)

        admin.services.send_mail.assert_has_calls([
            call('some_snap_id', 'some_group_id'),
            call(ANY, 'some_group_id')
        ])
        admin.services.upload_files_to_s3.assert_has_calls([
            call('some_snap_id', 'some_group_id'),
            call(ANY, 'some_group_id')
        ])
        admin.services.clean_up_files.assert_has_calls([
            call('some_snap_id', 'some_group_id'),
            call(ANY, 'some_group_id')
        ])
        assert return_value == {
            'snap_ids': ['some_snap_id', ANY, ANY],
            'group_id': 'some_group_id',
            'normal_exposure_pic_ids': [ANY, ANY, ANY],
            'long_exposure_pic_ids': [ANY, ANY, ANY]
        }
Beispiel #4
0
def picam_still():
    '''
    Api endpoint for taking one or a series of Picam stills.  
    The still/stills will run asynchronously as Celery tasks, the scheduling work is delegated to the camera.tasks module
    Delaying and Repeating info comes in via GET parameters, the rest comes from the current group record.
    '''
    snap_id = uuid.uuid4()
    group_id = get_settings_document()['current_group_id']
    delay = get_delay_parameter()
    repeat = get_repeat_parameter()
    ret_dict = take_picam_still(snap_id=snap_id, group_id=group_id, delay=delay, repeat=repeat)
    return Response(json.dumps(ret_dict), status=202, mimetype='application/json')
Beispiel #5
0
    def test_take_picam_still_calls_expected_methods_with_expected_values_when_clean_up_files_is_off(self):
        camera.services.take_picam_still = Mock()
        admin.services.send_mail = Mock()
        admin.services.upload_files_to_s3 = Mock()
        admin.services.clean_up_files = Mock()

        return_value = ct.take_picam_still('some_snap_id', 'some_group_id', clean_up_files=False)

        camera.services.take_picam_still.assert_called_once_with('some_snap_id', 'some_group_id', ANY, ANY, False)

        assert return_value == {'snap_ids': ['some_snap_id'],
                                'group_id': 'some_group_id',
                                'normal_exposure_pic_ids': [ANY],
                                'long_exposure_pic_ids': [ANY]}
Beispiel #6
0
def picam_still():
    '''
    Api endpoint for taking one or a series of Picam stills.  
    The still/stills will run asynchronously as Celery tasks, the scheduling work is delegated to the camera.tasks module
    Delaying and Repeating info comes in via GET parameters, the rest comes from the current group record.
    '''
    snap_id = uuid.uuid4()
    group_id = get_settings_document()['current_group_id']
    delay = get_delay_parameter()
    repeat = get_repeat_parameter()
    ret_dict = take_picam_still(snap_id=snap_id,
                                group_id=group_id,
                                delay=delay,
                                repeat=repeat)
    return Response(json.dumps(ret_dict),
                    status=202,
                    mimetype='application/json')
Beispiel #7
0
    def test_take_picam_still_calls_expected_methods_with_defaults_for_delay_repeat_clean_up_files(self):
        camera.services.take_picam_still = Mock()
        admin.services.send_mail = Mock()
        admin.services.upload_files_to_s3 = Mock()
        admin.services.clean_up_files = Mock()

        return_value = ct.take_picam_still('some_snap_id', 'some_group_id')

        camera.services.take_picam_still.assert_called_once_with('some_snap_id', 'some_group_id', ANY, ANY, True)

        admin.services.send_mail.assert_called_once_with('some_snap_id', 'some_group_id')
        admin.services.upload_files_to_s3.assert_called_once_with('some_snap_id', 'some_group_id')
        admin.services.clean_up_files.assert_called_once_with('some_snap_id', 'some_group_id')
        assert return_value == {'snap_ids': ['some_snap_id'],
                                'group_id': 'some_group_id',
                                'normal_exposure_pic_ids': [ANY],
                                'long_exposure_pic_ids': [ANY]}
Beispiel #8
0
    def test_take_picam_still_calls_expected_methods_with_nonzero_repeat(self):
        camera.services.take_picam_still = Mock()
        admin.services.send_mail = Mock()
        admin.services.upload_files_to_s3 = Mock()
        admin.services.clean_up_files = Mock()

        return_value = ct.take_picam_still('some_snap_id', 'some_group_id', delay=0, repeat=2)

        admin.services.send_mail.assert_has_calls([call('some_snap_id', 'some_group_id'),
                                                   call(ANY, 'some_group_id')])
        admin.services.upload_files_to_s3.assert_has_calls([call('some_snap_id', 'some_group_id'),
                                                            call(ANY, 'some_group_id')])
        admin.services.clean_up_files.assert_has_calls([call('some_snap_id', 'some_group_id'),
                                                        call(ANY, 'some_group_id')])
        assert return_value == {'snap_ids': ['some_snap_id', ANY, ANY],
                                'group_id': 'some_group_id',
                                'normal_exposure_pic_ids': [ANY, ANY, ANY],
                                'long_exposure_pic_ids': [ANY, ANY, ANY]}
Beispiel #9
0
    def test_take_picam_still_calls_expected_methods_with_expected_values_when_clean_up_files_is_off(
            self):
        camera.services.take_picam_still = Mock()
        admin.services.send_mail = Mock()
        admin.services.upload_files_to_s3 = Mock()
        admin.services.clean_up_files = Mock()

        return_value = ct.take_picam_still('some_snap_id',
                                           'some_group_id',
                                           clean_up_files=False)

        camera.services.take_picam_still.assert_called_once_with(
            'some_snap_id', 'some_group_id', ANY, ANY, False)

        assert return_value == {
            'snap_ids': ['some_snap_id'],
            'group_id': 'some_group_id',
            'normal_exposure_pic_ids': [ANY],
            'long_exposure_pic_ids': [ANY]
        }
Beispiel #10
0
def picam_still():
    '''
    Api endpoint for taking one or a series of Picam stills.
    The still/stills will run asynchronously as Celery tasks, the scheduling work is delegated to the camera.tasks module
    Cleaning up files comes in via a GET parameter, note that empty string is the ONLY thing that will force it to false
    Delaying and Repeating info comes in via GET parameters, the rest comes from the current group record.
    '''
    try:
        snap_id = uuid.uuid4()
        group_id = get_settings_document()['current_group_id']
        args_dict = gather_and_enforce_request_args([{'name': 'delay', 'default': 0, 'cast_function': int},
                                                     {'name': 'clean_up_files', 'default': True, 'cast_function': bool},
                                                     {'name': 'repeat', 'default': 0, 'cast_function': int}])
        # TODO specify that is (snap_id, group_id, **args_dict soon)
        ret_dict = take_picam_still(snap_id=snap_id,
                                    group_id=group_id,
                                    delay=args_dict['delay'],
                                    repeat=args_dict['repeat'],
                                    clean_up_files=args_dict['clean_up_files'])
        return Response(json.dumps(ret_dict), status=202, mimetype='application/json')
    except Exception as e:
        return Response(json.dumps(e.message), status=e.status_code, mimetype='application/json')
Beispiel #11
0
def picam_still():
    '''
    Api endpoint for taking one or a series of Picam stills.
    The still/stills will run asynchronously as Celery tasks, the scheduling work is delegated to the camera.tasks module
    Cleaning up files comes in via a GET parameter, note that empty string is the ONLY thing that will force it to false
    Delaying and Repeating info comes in via GET parameters, the rest comes from the current group record.
    '''
    try:
        snap_id = uuid.uuid4()
        group_id = get_settings_document()['current_group_id']
        args_dict = gather_and_enforce_request_args([{
            'name': 'delay',
            'default': 0,
            'cast_function': int
        }, {
            'name': 'clean_up_files',
            'default': True,
            'cast_function': bool
        }, {
            'name': 'repeat',
            'default': 0,
            'cast_function': int
        }])
        # TODO specify that is (snap_id, group_id, **args_dict soon)
        ret_dict = take_picam_still(snap_id=snap_id,
                                    group_id=group_id,
                                    delay=args_dict['delay'],
                                    repeat=args_dict['repeat'],
                                    clean_up_files=args_dict['clean_up_files'])
        return Response(json.dumps(ret_dict),
                        status=202,
                        mimetype='application/json')
    except Exception as e:
        return Response(json.dumps(e.message),
                        status=e.status_code,
                        mimetype='application/json')
Beispiel #12
0
    def test_take_picam_still_calls_expected_methods_with_defaults_for_delay_repeat_clean_up_files(
            self):
        camera.services.take_picam_still = Mock()
        admin.services.send_mail = Mock()
        admin.services.upload_files_to_s3 = Mock()
        admin.services.clean_up_files = Mock()

        return_value = ct.take_picam_still('some_snap_id', 'some_group_id')

        camera.services.take_picam_still.assert_called_once_with(
            'some_snap_id', 'some_group_id', ANY, ANY, True)

        admin.services.send_mail.assert_called_once_with(
            'some_snap_id', 'some_group_id')
        admin.services.upload_files_to_s3.assert_called_once_with(
            'some_snap_id', 'some_group_id')
        admin.services.clean_up_files.assert_called_once_with(
            'some_snap_id', 'some_group_id')
        assert return_value == {
            'snap_ids': ['some_snap_id'],
            'group_id': 'some_group_id',
            'normal_exposure_pic_ids': [ANY],
            'long_exposure_pic_ids': [ANY]
        }