Пример #1
0
    def test_generic_list_view_catches_exceptions(self, tv_search_generic):

        tv_search_generic.side_effect = ThermalBaseError('phenomenon')

        resp_object = tv.generic_list_view(document_type='picture')
        assert resp_object.data == '"phenomenon"'
        assert resp_object.status_code == 400
Пример #2
0
    def test_both_still_catches_exceptions(self,
                                           cv_get_settings_document):

        cv_get_settings_document.side_effect = ThermalBaseError('gouda')

        resp_object = cv.both_still()
        assert resp_object.data == '"gouda"'
        assert resp_object.status_code == 400
Пример #3
0
    def test_call_merge_images_handles_exception(self,
                                                 mv_gather_and_enforce_request_args):

        mv_gather_and_enforce_request_args.side_effect = ThermalBaseError('careless_whisper')

        resp_object = mv.call_merge_images()
        assert resp_object.data == '"careless_whisper"'
        assert resp_object.status_code == 400
Пример #4
0
    def test_picam_still_catches_exceptions(self,
                                            cv_get_settings_document):

        cv_get_settings_document.side_effect = ThermalBaseError('gruyere')

        resp_object = cv.picam_still()
        assert resp_object.data == '"gruyere"'
        assert resp_object.status_code == 400
Пример #5
0
    def test_get_settings_catches_exceptions(self, av_get_settings_document):

        av_get_settings_document.side_effect = ThermalBaseError(
            'blowing every time you move your teeth')

        resp_object = av.get_settings()
        assert resp_object.data == '"blowing every time you move your teeth"'
        assert resp_object.status_code == 400
Пример #6
0
    def test_update_group_catches_exceptions(self, av_get_group_document):

        av_get_group_document.side_effect = ThermalBaseError(
            'Blowing through the curtains in your room')

        resp_object = av.update_group('brockman')
        assert resp_object.data == '"Blowing through the curtains in your room"'
        assert resp_object.status_code == 400
Пример #7
0
    def test_thermal_still_catches_exceptions(self,
                                              cv_get_settings_document):

        cv_get_settings_document.side_effect = ThermalBaseError('emmenthaler')

        resp_object = cv.thermal_still()
        assert resp_object.data == '"emmenthaler"'
        assert resp_object.status_code == 400
Пример #8
0
    def test_take_picam_still_chained_catches_exception(
            self, cs_take_picam_still, ct_log_asynchronous_exception):
        the_exception = ThermalBaseError('steve_wilkos')
        cs_take_picam_still.side_effect = the_exception

        ct.take_picam_still_chained('a', 'b', 'c', 'd', 'e', 'f')

        cs_take_picam_still.assert_called_once_with('b', 'c', 'd', 'e', 'f')
        ct_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #9
0
    def test_thermal_still_task_catches_exception(
            self, cs_take_thermal_still, ct_log_asynchronous_exception):
        the_exception = ThermalBaseError('bill_cunningham')
        cs_take_thermal_still.side_effect = the_exception

        ct.thermal_still_task('a', 'b', 'c', 'd')

        cs_take_thermal_still.assert_called_once_with('a', 'b', 'c', 'd')
        ct_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #10
0
    def test_update_settings_catches_exceptions(self,
                                                av_get_settings_document):

        av_get_settings_document.side_effect = ThermalBaseError(
            'Someones got it in for me, theyre planting stories in the press')

        resp_object = av.update_settings()
        assert resp_object.data == '"Someones got it in for me, theyre planting stories in the press"'
        assert resp_object.status_code == 400
Пример #11
0
    def test_picam_still_task_catches_exception(self, cs_take_picam_still,
                                                ct_log_asynchronous_exception):
        the_exception = ThermalBaseError('wendy_williams')
        cs_take_picam_still.side_effect = the_exception

        ct.picam_still_task('a', 'b', 'c', 'd', 'e')

        cs_take_picam_still.assert_called_once_with('a', 'b', 'c', 'd', 'e')
        ct_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #12
0
    def test_scale_image_chained_catches_exception(
            self, as_scale_image, as_log_asynchronous_exception):
        the_exception = ThermalBaseError('dante_culpepper')
        as_scale_image.side_effect = the_exception

        ans.scale_image_chained('a', 'b', 'c', 'd')

        as_scale_image.assert_called_once_with('b', 'c', 'd')
        as_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #13
0
    def test_scale_image_task_catches_exception(self, as_scale_image,
                                                as_log_asynchronous_exception):
        the_exception = ThermalBaseError('carlton_fisk')
        as_scale_image.side_effect = the_exception

        ans.scale_image_task('a', 'b', 'c')

        as_scale_image.assert_called_once_with('a', 'b', 'c')
        as_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #14
0
    def test_send_mail_chained_catches_exception(
            self, as_send_mail, at_log_asynchronous_exception):
        the_exception = ThermalBaseError('geraldo_rivera')
        as_send_mail.side_effect = the_exception

        admt.send_mail_chained('a', 'b', 'c')

        as_send_mail.assert_called_once_with('b', 'c')
        at_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #15
0
    def test_clean_up_files_chained_catches_exception(
            self, as_clean_up_files, at_log_asynchronous_exception):
        the_exception = ThermalBaseError('sally_jesse_rafael')
        as_clean_up_files.side_effect = the_exception

        admt.clean_up_files_chained('a', 'b', 'c')

        as_clean_up_files.assert_called_once_with('b', 'c')
        at_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #16
0
    def test_clean_up_files_task_catches_exception(
            self, as_clean_up_files, at_log_asynchronous_exception):
        the_exception = ThermalBaseError('phil_donahue')
        as_clean_up_files.side_effect = the_exception

        admt.clean_up_files_task('a', 'b')

        as_clean_up_files.assert_called_once_with('a', 'b')
        at_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #17
0
    def test_upload_files_to_s3_task_catches_exception(
            self, as_upload_files_to_s3, at_log_asynchronous_exception):
        the_exception = ThermalBaseError('merv_griffin')
        as_upload_files_to_s3.side_effect = the_exception

        admt.upload_files_to_s3_task('a', 'b')

        as_upload_files_to_s3.assert_called_once_with('a', 'b')
        at_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #18
0
 def test_generic_save_view_handles_abend(self, tv_save_generic):
     tv_save_generic.side_effect = ThermalBaseError('phenomenon')
     with current_app.test_request_context(
             '/whatever',
             headers={'Content-Type': 'application/json'},
             data='{"thermo":"plastic"}'):
         resp_object = tv.generic_save_view(args_dict={'feed': 'bag'},
                                            document_type='headache')
         assert resp_object.status_code == 400
         assert resp_object.data == '"phenomenon"'
Пример #19
0
    def test_call_distort_image_handles_exception(
            self, av_get_document_with_exception):

        av_get_document_with_exception.side_effect = ThermalBaseError(
            'bill_dauterive')

        resp_object = av.call_distort_image(image_id='starting_image_id')

        assert resp_object.data == '"bill_dauterive"'
        assert resp_object.status_code == 400
Пример #20
0
    def test_distort_image_shepards_task_catches_exception(
            self, as_distort_image_shepards, as_log_asynchronous_exception):
        the_exception = ThermalBaseError('matt_forte')
        as_distort_image_shepards.side_effect = the_exception

        ans.distort_image_shepards_task('a', 'b', 'c')

        as_distort_image_shepards.assert_called_once_with(
            image_id_in='a', image_id_out='b', distortion_set_id='c')
        as_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #21
0
    def test_distort_image_shepards_chained_catches_exception(
            self, as_distort_image_shepards, as_log_asynchronous_exception):
        the_exception = ThermalBaseError('bo_jackson')
        as_distort_image_shepards.side_effect = the_exception

        ans.distort_image_shepards_chained('a', 'b', 'c')

        as_distort_image_shepards.assert_called_once_with(
            image_id_in='b', image_id_out='c', distortion_set_id=None)
        as_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #22
0
    def test_call_edge_detect_handles_exceptions(
            self, av_get_document_with_exception):
        av_get_document_with_exception.side_effect = ThermalBaseError(
            'dale gribble')

        resp_object = av.call_edge_detect(image_id='5454')

        av_get_document_with_exception.assert_called_once_with(
            '5454', document_type='picture')
        assert resp_object.data == '"dale gribble"'
        assert resp_object.status_code == 400
Пример #23
0
    def test_edge_detect_task_catches_exception(self, as_edge_detect,
                                                as_log_asynchronous_exception):
        the_exception = ThermalBaseError('trent_dilfer')
        as_edge_detect.side_effect = the_exception

        ans.edge_detect_task('a',
                             detection_threshold='b',
                             auto_id='c',
                             wide_id='d',
                             tight_id='e')

        as_edge_detect.assert_called_once_with('a', 'b', 'c', 'd', 'e')
        as_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #24
0
    def test_merge_images_task_catches_exception(
            self, ms_merge_images, ms_log_asynchronous_exception):
        the_exception = ThermalBaseError('wendy_williams')
        ms_merge_images.side_effect = the_exception

        ms.merge_images_task('a', 'b', 'c', 'd', 'e')

        ms_merge_images.assert_called_once_with(img1_primary_id_in='a',
                                                img1_alternate_id_in='b',
                                                img2_id_in='c',
                                                img_id_out='d',
                                                group_id='e')
        ms_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #25
0
    def test_create_distortion_pair_catches_exception(self, cv_item_exists,
                                                      cv_save_generic,
                                                      cv_generic_save_view):

        cv_item_exists.side_effect = ThermalBaseError('zaboomafoo')
        with current_app.test_request_context(
                '/whatever',
                headers={'Content-Type': 'application/json'},
                data='{"distortion_set_id":"umma_gumma", "start_x": "55"}'):
            resp_object = cv.create_distortion_pair()
            cv_item_exists.assert_called_once_with('umma_gumma',
                                                   'distortion_set')
            assert resp_object.data == '"zaboomafoo"'
            assert resp_object.status_code == 400
Пример #26
0
    def test_edge_detect_chained_catches_exception(
            self, as_edge_detect, as_log_asynchronous_exception):
        the_exception = ThermalBaseError('donovan_mcnabb')
        as_edge_detect.side_effect = the_exception

        ans.edge_detect_chained('a',
                                'b',
                                detection_threshold='c',
                                auto_id='d',
                                wide_id='e',
                                tight_id='f')

        as_edge_detect.assert_called_once_with('b', 'c', 'd', 'e', 'f')
        as_log_asynchronous_exception.assert_called_once_with(the_exception)
Пример #27
0
    def test_save_group_handles_exception_in_settings_stuff(
            self, av_get_settings_document, av_default_group_dict,
            av_generic_save_view):
        av_generic_save_view.return_value = Response('{"_id": "bob_loblaw"}',
                                                     status=200)
        default_group_dict = {'roger_murtaugh': 'too old for this shiznit'}
        av_default_group_dict.return_value = default_group_dict
        av_get_settings_document.side_effect = ThermalBaseError(
            'unpleasantness')

        resp_object = av.save_group()

        av_generic_save_view.assert_called_once_with(
            args_dict=default_group_dict, document_type='group')
        av_get_settings_document.assert_called_once_with()
        assert resp_object.data == '"error saving settings: unpleasantness"'
        assert resp_object.status_code == 400
Пример #28
0
    def test_scale_image_accepts_scale_type_through_group_record(
            self, as_scale_image_subtask, as_build_picture_path,
            as_build_picture_name, as_get_document_with_exception,
            as_get_group_document):

        as_get_group_document.return_value = {
            '_id': 'd1',
            'scale_type': 'group_scale_type'
        }
        as_scale_image_subtask.side_effect = ThermalBaseError('wocka_wocka')
        Image.open = Mock(return_value='ali_baba')
        as_build_picture_path.return_value = 'steve_mcnair'
        as_build_picture_name.return_value = 'mongo_mcmichael'
        as_get_document_with_exception.return_value = {
            'filename': 'a1',
            'uri': 'b1',
            'snap_id': 'c1'
        }

        with pytest.raises(ThermalBaseError) as exception_info:
            return_value = ans.scale_image('a', 'b', 'c')

        as_scale_image_subtask.assert_called_once_with('group_scale_type', ANY)