예제 #1
0
    def test_call_edge_detect_calls_appropriate_methods_for_defaults(
            self, av_edge_detect_task_delay,
            av_gather_and_enforce_request_args,
            av_get_document_with_exception):
        av_get_document_with_exception.return_value = {'hamburger': 'man'}
        av_gather_and_enforce_request_args.return_value = {
            'detection_threshold': 'all'
        }

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

        av_get_document_with_exception.assert_called_once_with(
            '5454', document_type='picture')
        av_gather_and_enforce_request_args.assert_called_once_with([{
            'name':
            'detection_threshold',
            'default':
            'all'
        }])

        av_edge_detect_task_delay.assert_called_once_with(
            img_id_in='5454',
            detection_threshold='all',
            auto_id=ANY,
            wide_id=ANY,
            tight_id=ANY)
        response_data_dict = json.loads(resp_object.data)
        assert 'auto_id' in response_data_dict
        assert 'wide_id' in response_data_dict
        assert 'tight_id' in response_data_dict
        assert len(response_data_dict.keys()) == 3

        assert resp_object.status_code == 202
예제 #2
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
예제 #3
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
예제 #4
0
    def test_call_edge_detect_handles_bad_detection_threshold(self,
                                                              av_gather_and_enforce_request_args,
                                                              av_get_document_with_exception):
        av_get_document_with_exception.return_value = {'hamburger': 'man'}
        av_gather_and_enforce_request_args.return_value = {'detection_threshold': 'monkey_chow'}

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

        av_get_document_with_exception.assert_called_once_with('5454', document_type='picture')
        av_gather_and_enforce_request_args.assert_called_once_with([{'name': 'detection_threshold', 'default': 'all'}])
        assert resp_object.data == '"invalid detection threshold specified.  Allowable are all, auto, wide or tight"'
        assert resp_object.status_code == 409
예제 #5
0
    def test_call_edge_detect_handles_bad_detection_threshold(
            self, av_gather_and_enforce_request_args,
            av_get_document_with_exception):
        av_get_document_with_exception.return_value = {'hamburger': 'man'}
        av_gather_and_enforce_request_args.return_value = {
            'detection_threshold': 'monkey_chow'
        }

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

        av_get_document_with_exception.assert_called_once_with(
            '5454', document_type='picture')
        av_gather_and_enforce_request_args.assert_called_once_with([{
            'name':
            'detection_threshold',
            'default':
            'all'
        }])
        assert resp_object.data == '"invalid detection threshold specified.  Allowable are all, auto, wide or tight"'
        assert resp_object.status_code == 409
예제 #6
0
    def test_call_edge_detect_calls_appropriate_methods_for_defaults(self,
                                                                     av_edge_detect_task_delay,
                                                                     av_gather_and_enforce_request_args,
                                                                     av_get_document_with_exception):
        av_get_document_with_exception.return_value = {'hamburger': 'man'}
        av_gather_and_enforce_request_args.return_value = {'detection_threshold': 'all'}

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

        av_get_document_with_exception.assert_called_once_with('5454', document_type='picture')
        av_gather_and_enforce_request_args.assert_called_once_with([{'name': 'detection_threshold', 'default': 'all'}])

        av_edge_detect_task_delay.assert_called_once_with(img_id_in='5454',
                                                          detection_threshold='all',
                                                          auto_id=ANY,
                                                          wide_id=ANY,
                                                          tight_id=ANY)
        response_data_dict = json.loads(resp_object.data)
        assert 'auto_id' in response_data_dict
        assert 'wide_id' in response_data_dict
        assert 'tight_id' in response_data_dict
        assert len(response_data_dict.keys()) == 3

        assert resp_object.status_code == 202