示例#1
0
    def test_generic_update_view_fails_when_document_not_present(self,
                                                                 tv_get_document_with_exception):

        tv_get_document_with_exception.side_effect = NotFoundError('no picture there, friend')

        resp_object = tv.generic_update_view(item_id='4231', document_type='misunderstanding')

        tv_get_document_with_exception.assert_called_once_with('4231', 'misunderstanding')
        assert resp_object.status_code == 404
        assert resp_object.data == '"no picture there, friend"'
示例#2
0
    def test_generic_update_view_fails_when_document_not_present(
            self, tv_get_document_with_exception):

        tv_get_document_with_exception.side_effect = NotFoundError(
            'no picture there, friend')

        resp_object = tv.generic_update_view(item_id='4231',
                                             document_type='misunderstanding')

        tv_get_document_with_exception.assert_called_once_with(
            '4231', 'misunderstanding')
        assert resp_object.status_code == 404
        assert resp_object.data == '"no picture there, friend"'
示例#3
0
    def test_generic_update_view_handles_non_json_data(self,
                                                       tv_get_document_with_exception):

        tv_get_document_with_exception.return_value = {'xena': 'warrior_princess'}
        with current_app.test_request_context('/whatever',
                                              headers={'Content-Type':'application/not_json'},
                                              data='{"cant_drive": "55"}'):
            resp_object = tv.generic_update_view(item_id='wango', document_type='tango')

            tv_get_document_with_exception.assert_called_once_with('wango', 'tango')

            assert resp_object.status_code == 409
            assert resp_object.data == '"problem with update: content type is not application/json"'
示例#4
0
    def test_generic_update_view_adds_request_args_parms_to_item(self,
                                                                 tv_get_document_with_exception,
                                                                 tv_update_generic):
        tv_get_document_with_exception.return_value = {'e': 'd', 'thermo': 'set'}
        with current_app.test_request_context('/whatever',
                                              headers={'Content-Type':'application/json'},
                                              data='{"thermo":"plastic", "monkey": "chow"}'):
            resp_object = tv.generic_update_view(item_id='1234', document_type='headache')

            assert resp_object.status_code == 200
            the_dict = json.loads(resp_object.data) 
            assert the_dict == {'thermo': 'plastic',
                                'monkey': 'chow',
                                'e': 'd'}
            tv_get_document_with_exception.assert_called_once_with('1234', 'headache')
            tv_update_generic.assert_called_once_with(the_dict, 'headache')
示例#5
0
    def test_generic_update_view_handles_non_json_data(
            self, tv_get_document_with_exception):

        tv_get_document_with_exception.return_value = {
            'xena': 'warrior_princess'
        }
        with current_app.test_request_context(
                '/whatever',
                headers={'Content-Type': 'application/not_json'},
                data='{"cant_drive": "55"}'):
            resp_object = tv.generic_update_view(item_id='wango',
                                                 document_type='tango')

            tv_get_document_with_exception.assert_called_once_with(
                'wango', 'tango')

            assert resp_object.status_code == 409
            assert resp_object.data == '"problem with update: content type is not application/json"'
示例#6
0
    def test_generic_update_view_adds_request_args_parms_to_item(
            self, tv_get_document_with_exception, tv_update_generic):
        tv_get_document_with_exception.return_value = {
            'e': 'd',
            'thermo': 'set'
        }
        with current_app.test_request_context(
                '/whatever',
                headers={'Content-Type': 'application/json'},
                data='{"thermo":"plastic", "monkey": "chow"}'):
            resp_object = tv.generic_update_view(item_id='1234',
                                                 document_type='headache')

            assert resp_object.status_code == 200
            the_dict = json.loads(resp_object.data)
            assert the_dict == {
                'thermo': 'plastic',
                'monkey': 'chow',
                'e': 'd'
            }
            tv_get_document_with_exception.assert_called_once_with(
                '1234', 'headache')
            tv_update_generic.assert_called_once_with(the_dict, 'headache')
示例#7
0
def update_snap(snap_id):
    '''
    Updates an individual snap
    '''
    return generic_update_view(item_id=snap_id, document_type='snap')
示例#8
0
文件: views.py 项目: dcaulton/thermal
def update_snap(snap_id):
    '''
    Updates an individual snap
    '''
    return generic_update_view(item_id=snap_id, document_type='snap')
示例#9
0
文件: views.py 项目: dcaulton/thermal
def update_distortion_pair(distortion_pair_id):
    return generic_update_view(item_id=distortion_pair_id, document_type='distortion_pair')
示例#10
0
文件: views.py 项目: dcaulton/thermal
def update_distortion_set(distortion_set_id):
    return generic_update_view(item_id=distortion_set_id, document_type='distortion_set')
示例#11
0
文件: views.py 项目: dcaulton/thermal
def update_calibration_session(calibration_session_id):
    return generic_update_view(item_id=calibration_session_id, document_type='calibration_session')
示例#12
0
def update_distortion_pair(distortion_pair_id):
    return generic_update_view(item_id=distortion_pair_id,
                               document_type='distortion_pair')
示例#13
0
def update_distortion_set(distortion_set_id):
    return generic_update_view(item_id=distortion_set_id,
                               document_type='distortion_set')
示例#14
0
def update_calibration_session(calibration_session_id):
    return generic_update_view(item_id=calibration_session_id,
                               document_type='calibration_session')