def client_anonymous_login( as_test=True, only_access_token=False, ): # server_api = get_server_api() # log_.debug("=== client_anonymous_login / server_api : %s", server_api) # url = f"{server_api}{config.API_V1_STR}/anonymous_login" url = f"{config.API_V1_STR}/anonymous_login" # log_.debug("=== url : %s", url) # response = requests.get( response = client.get(url, ) resp = response.json() # log_.debug("=== client_anonymous_login / resp : \n%s", pformat( resp )) if as_test: assert response.status_code == 200 else: if only_access_token: return resp['tokens']['access_token'] else: return resp
def get_one_dsr( as_test=True, only_test_data=False, dsi_uuid=None, access_token=None, ): server_api = get_server_api() # log_.debug('=== server_api : %s', server_api) ### get test user if access_token == None: test_user_access_token = client_login(as_test=False, only_access_token=True) else: test_user_access_token = access_token log_.debug('=== update_one_dsr / test_user_access_token : %s', test_user_access_token) ### get DSI UUID if dsi_uuid == None: test_dsi = create_one_dsi(as_test=False) assert test_dsi['data']['is_test_data'] == True test_dsi_uuid = test_dsi['data']['dsi_uuid'] else: test_dsi_uuid = dsi_uuid log_.debug('=== test_get_one_dsr / test_dsi_uuid : %s', test_dsi_uuid) ### get DSR UUID test_dsr = create_one_dsr(as_test=False, dsi_uuid=test_dsi_uuid) log_.debug('=== test_get_one_dsr / test_dsr : \n%s', pformat(test_dsr)) test_dsr_uuid = test_dsr['data']['dsr_uuid'] log_.debug('=== test_get_one_dsr / test_dsr_uuid : %s', test_dsr_uuid) headers = { 'accept': 'application/json', 'access_token': test_user_access_token, } # url = f"{server_api}{config.API_V1_STR}/crud/dataset/{test_dsi_uuid}/dsr/get_one/{test_dsr_uuid}" url = f"{config.API_V1_STR}/crud/dataset/{test_dsi_uuid}/dsr/get_one/{test_dsr_uuid}" ### get DSRs list # response = requests.get( response = client.get(url, headers=headers) resp = response.json() log_.debug('=== test_get_one_dsr / resp : \n%s', pformat(resp)) if as_test: assert response.status_code == 200 else: return resp
def get_list_dsr(as_test=True, page_number=1, results_per_page=100, dsi_uuid=None, access_token=None): # server_api = get_server_api() # log_.debug('=== server_api : %s', server_api) if access_token == None: test_user_access_token = client_login(as_test=False, only_access_token=True) else: test_user_access_token = access_token log_.debug('=== test_user_access_token : %s', test_user_access_token) if dsi_uuid == None: test_dsi = create_one_dsi(as_test=False, access_token=test_user_access_token) assert test_dsi['data']['is_test_data'] == True test_dsi_uuid = test_dsi['data']['dsi_uuid'] else: test_dsi_uuid = dsi_uuid log_.debug('=== get_list_dsr / test_dsi_uuid : %s', test_dsi_uuid) headers = { 'accept': 'application/json', 'access_token': test_user_access_token, } params = {'page_n': page_number, 'per_page': results_per_page} # url = f"{server_api}{config.API_V1_STR}/crud/dataset/{test_dsi_uuid}" url = f"{config.API_V1_STR}/crud/dataset/{test_dsi_uuid}" # response = requests.get( response = client.get(url, params=params, headers=headers) resp = response.json() log_.debug('=== get_list_dsr / resp : \n%s', pformat(resp)) if as_test: assert response.status_code == 200 or resp['data'] == [] else: return resp
def get_one_dsi(as_test=True, only_test_data=False, dsi_uuid=None, access_token=None, params=None): server_api = get_server_api() log_.debug('=== test_get_one_dsi / server_api : %s', server_api) ### get test user if access_token == None: test_user_access_token = client_login(as_test=False, only_access_token=True) else: test_user_access_token = access_token ### dsi if dsi_uuid == None: # test_dsi_uuid = '3ffbacf768f1481cb2b8968381490a72' # test_dsi_uuid = get_random_dsi_uuid( only_test_dsi = only_test_data ) test_dsi = create_one_dsi(as_test=False) assert test_dsi['data']['is_test_data'] == True test_dsi_uuid = test_dsi['data']['dsi_uuid'] else: test_dsi_uuid = dsi_uuid log_.debug('=== test_get_one_dsi / test_dsi_uuid : %s', test_dsi_uuid) headers = { 'accept': 'application/json', 'access_token': test_user_access_token, } # url = f"{server_api}{config.API_V1_STR}/dsi/get_one/{test_dsi_uuid}" url = f"{config.API_V1_STR}/dsi/get_one/{test_dsi_uuid}" # response = requests.get( response = client.get(url, headers=headers) resp = response.json() log_.debug('=== test_get_one_dsi / resp : \n%s', pformat(resp)) if as_test: assert response.status_code == 200 else: return resp
def get_list_dsi( as_test=True, page_number=1, results_per_page=100, access_token=None, params=None, ): # server_api = get_server_api() # log_.debug('=== get_list_dsi / server_api : %s', server_api) if access_token == None: test_user_access_token = client_login(as_test=False, only_access_token=True) else: test_user_access_token = access_token log_.debug('=== test_user_access_token : %s', test_user_access_token) if params == None: params = {'page_n': page_number, 'per_page': results_per_page} headers = { 'accept': 'application/json', 'access_token': test_user_access_token, } # url = f"{server_api}{config.API_V1_STR}/dsi/list", url = f"{config.API_V1_STR}/dsi/list" # response = requests.get( response = client.get(url, params=params, headers=headers) resp = response.json() # log_.debug ('=== resp : \n%s', pformat(resp) ) if as_test: log_.debug('=== get_list_dsi / resp : \n%s', pformat(resp)) assert response.status_code == 200 else: return resp
def test_run_client_docs(): response = client.get("/docs") assert response.status_code == 200