def test_generic_list_view_calls_search_generic_with_supplied_args_dict( self, tv_search_generic): tv_search_generic.return_value = {} resp_object = tv.generic_list_view( document_type='something', args_dict={'detroit': 'grand_poobahs'}) tv.search_generic.assert_called_once_with( document_type='something', args_dict={'detroit': 'grand_poobahs'})
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
def list_groups(): ''' Lists all groups Includes paging and searching on any field in the group document ''' # If no settings or groups yet create a group group_dict = get_group_document('current') return generic_list_view(document_type='group')
def test_generic_list_view_calls_search_generic(self, tv_search_generic): tv_search_generic.return_value = {'1212': {'_id': '1212'}, '2323': {'_id': '2323'}} resp_object = tv.generic_list_view(document_type='something') tv.search_generic.assert_called_once_with(document_type='something', args_dict={}) response_data_dict = json.loads(resp_object.data) assert resp_object.status_code == 200 assert '1212' in response_data_dict assert '2323' in response_data_dict assert len(response_data_dict.keys()) == 2
def get_group_gallery(group_id): ''' Fetches the photo gallery for a supplied group id Includes paging and searching on any field in the picture document ''' try: group_dict = get_group_document(group_id) group_id = group_dict['_id'] return generic_list_view(document_type='picture', args_dict={'group_id': group_id, 'gallery_url_not_null': True}) except Exception as e: return Response(json.dumps(e.message), status=e.status_code, mimetype='application/json')
def get_group_pictures(group_id): ''' Fetches pictures for a supplied group id Includes paging and searching on any field in the picture document ''' try: group_dict = get_group_document(group_id) group_id = group_dict['_id'] return generic_list_view(document_type='picture', args_dict={'group_id': group_id}) except Exception as e: return Response(json.dumps(e.message), status=e.status_code, mimetype='application/json')
def test_generic_list_view_calls_search_generic(self, tv_search_generic): tv_search_generic.return_value = { '1212': { '_id': '1212' }, '2323': { '_id': '2323' } } resp_object = tv.generic_list_view(document_type='something') tv.search_generic.assert_called_once_with(document_type='something', args_dict={}) response_data_dict = json.loads(resp_object.data) assert resp_object.status_code == 200 assert '1212' in response_data_dict assert '2323' in response_data_dict assert len(response_data_dict.keys()) == 2
def list_calibration_sessions(): ''' Lists all calibration sessions Supports paging and filtering on any attribute via get parms ''' return generic_list_view(document_type='calibration_session')
def list_distortion_pairs(): ''' Lists all distortion pairs Supports paging and filtering on any attribute via get parms ''' return generic_list_view(document_type='distortion_pair')
def list_snaps(): ''' Lists all snaps Supports paging and filtering on any attribute via get parms ''' return generic_list_view(document_type='snap')
def test_generic_list_view_calls_search_generic_with_supplied_args_dict(self, tv_search_generic): tv_search_generic.return_value = {} resp_object = tv.generic_list_view(document_type='something', args_dict={'detroit': 'grand_poobahs'}) tv.search_generic.assert_called_once_with(document_type='something', args_dict={'detroit': 'grand_poobahs'})
def list_pictures(): ''' Lists all pictures Supports paging and filtering on any picture attribute via get parms ''' return generic_list_view(document_type='picture')