示例#1
0
    def test_generic_get_view_fails_as_expected(self,
                                                tv_get_document_with_exception):
        tv_get_document_with_exception.side_effect = NotFoundError('no picture there, friend')

        resp_object = tv.generic_get_view(item_id='4231', document_type='misunderstanding')
        response_data_dict = json.loads(resp_object.data)

        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_get_view_calls_get_document_with_exception_method(self,
                                                                       tv_get_document_with_exception):
        tv_get_document_with_exception.return_value = {'e': 'd'}

        resp_object = tv.generic_get_view(item_id='4231', document_type='dirty_look')
        response_data_dict = json.loads(resp_object.data)

        tv_get_document_with_exception.assert_called_once_with('4231', 'dirty_look')
        assert resp_object.status_code == 200
        assert 'e' in response_data_dict
        assert len(response_data_dict.keys()) == 1
示例#3
0
    def test_generic_get_view_fails_as_expected(
            self, tv_get_document_with_exception):
        tv_get_document_with_exception.side_effect = NotFoundError(
            'no picture there, friend')

        resp_object = tv.generic_get_view(item_id='4231',
                                          document_type='misunderstanding')
        response_data_dict = json.loads(resp_object.data)

        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"'
示例#4
0
    def test_generic_get_view_calls_get_document_with_exception_method(
            self, tv_get_document_with_exception):
        tv_get_document_with_exception.return_value = {'e': 'd'}

        resp_object = tv.generic_get_view(item_id='4231',
                                          document_type='dirty_look')
        response_data_dict = json.loads(resp_object.data)

        tv_get_document_with_exception.assert_called_once_with(
            '4231', 'dirty_look')
        assert resp_object.status_code == 200
        assert 'e' in response_data_dict
        assert len(response_data_dict.keys()) == 1
示例#5
0
def get_snap(snap_id):
    '''
    Fetches an individual snap
    '''
    return generic_get_view(item_id=snap_id, document_type='snap')
示例#6
0
文件: views.py 项目: dcaulton/thermal
def get_snap(snap_id):
    '''
    Fetches an individual snap
    '''
    return generic_get_view(item_id=snap_id, document_type='snap')
示例#7
0
文件: views.py 项目: dcaulton/thermal
def get_picture(picture_id):
    '''
    Retrieves a picture for the supplied id
    '''
    return generic_get_view(item_id=picture_id, document_type='picture')
示例#8
0
文件: views.py 项目: ibivibiv/thermal
def get_picture(picture_id):
    '''
    Retrieves a picture for the supplied id
    '''
    return generic_get_view(item_id=picture_id, document_type='picture')
示例#9
0
文件: views.py 项目: dcaulton/thermal
def get_distortion_pair(distortion_pair_id):
    '''
    Fetches an individual distortion pair
    '''
    return generic_get_view(item_id=distortion_pair_id, document_type='distortion_pair')
示例#10
0
文件: views.py 项目: dcaulton/thermal
def get_distortion_set(distortion_set_id):
    '''
    Fetches an individual distortion set
    '''
    return generic_get_view(item_id=distortion_set_id, document_type='distortion_set')
示例#11
0
文件: views.py 项目: dcaulton/thermal
def get_calibration_session(calibration_session_id):
    '''
    Fetches an individual calibration session
    '''
    return generic_get_view(item_id=calibration_session_id, document_type='calibration_session')
示例#12
0
def get_distortion_pair(distortion_pair_id):
    '''
    Fetches an individual distortion pair
    '''
    return generic_get_view(item_id=distortion_pair_id,
                            document_type='distortion_pair')
示例#13
0
def get_distortion_set(distortion_set_id):
    '''
    Fetches an individual distortion set
    '''
    return generic_get_view(item_id=distortion_set_id,
                            document_type='distortion_set')
示例#14
0
def get_calibration_session(calibration_session_id):
    '''
    Fetches an individual calibration session
    '''
    return generic_get_view(item_id=calibration_session_id,
                            document_type='calibration_session')