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"'
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
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"'
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
def get_snap(snap_id): ''' Fetches an individual snap ''' return generic_get_view(item_id=snap_id, document_type='snap')
def get_picture(picture_id): ''' Retrieves a picture for the supplied id ''' return generic_get_view(item_id=picture_id, document_type='picture')
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')
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')
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')