def test_get_api_success(): #inserting for get filename = "create_api_for_success.json" request_data = setup.get_data(filename, file_path) headers = {'content-type': 'application/json'} service_url_upload = setup.get_api_url("insert") setup.send_post_request(service_url_upload, request_data, headers) service_url_get = setup.get_api_url( "get", ("Audiobook", "2EB8AA08-AA98-11EA-B4AA-73B441D16381")) headers = {'content-type': 'application/json'} response = setup.send_get_request(service_url_get, headers) service_url_get = setup.get_api_url("get_special", ("Audiobook", )) print(service_url_get) headers = {'content-type': 'application/json'} response_special = setup.send_get_request(service_url_get, headers) service_url_delete = setup.get_api_url( "delete", ("Audiobook", "2EB8AA08-AA98-11EA-B4AA-73B441D16381")) headers = {'content-type': 'application/json'} setup.send_delete_request(service_url_delete, headers) assert response.status_code == 200 assert response_special.status_code == 200
def test_delete_api_fail(): service_url_delete = setup.get_api_url("delete", ("Audiobook", "2EB8AA08-AA98-11EA-73B441D16381")) headers = {'content-type': 'application/json'} response = setup.send_delete_request(service_url_delete,headers) assert response.status_code == 400
def test_create_api_success(): filename = "create_api_for_success.json" request_data = setup.get_data(filename, file_path) headers = {'content-type': 'application/json'} service_url_upload = setup.get_api_url("insert") response = setup.send_post_request(service_url_upload, request_data, headers) #for cleaning service_url_delete = setup.get_api_url( "delete", ("Audiobook", "2EB8AA08-AA98-11EA-B4AA-73B441D16381")) headers = {'content-type': 'application/json'} print(service_url_delete) setup.send_delete_request(service_url_delete, headers) assert response.status_code == 200
def test_create_api_fail(): filename = "create_api_for_fail.json" request_data = setup.get_data(filename, file_path) headers = {'content-type': 'application/json'} service_url_upload = setup.get_api_url("insert") response = setup.send_post_request(service_url_upload, request_data, headers) assert response.status_code == 400
def test_update_api_norecord(): filename = "create_api_for_success.json" request_data = setup.get_data(filename, file_path) service_url_update = setup.get_api_url( "update", ("Audiobook", "2EB8AA08-AA98-11EA-B4AA-73B441D16385")) headers = {'content-type': 'application/json'} response = setup.send_update_request(service_url_update, request_data, headers) assert response.status_code == 400
def test_update_api_fail(): filename = "create_api_for_success.json" request_data = setup.get_data(filename, file_path) headers = {'content-type': 'application/json'} service_url_upload = setup.get_api_url("insert") setup.send_post_request(service_url_upload, request_data, headers) service_url_update = setup.get_api_url( "update", ("Song", "2EB8AA08-AA98-11EA-B4AA-73B441D16381")) print(service_url_update) headers = {'content-type': 'application/json'} request_data['audioMetadata']["audiobook_title"] = "updated" response = setup.send_update_request(service_url_update, request_data, headers) #for cleaning service_url_delete = setup.get_api_url( "delete", ("Audiobook", "2EB8AA08-AA98-11EA-B4AA-73B441D16381")) headers = {'content-type': 'application/json'} setup.send_delete_request(service_url_delete, headers) assert response.status_code == 400
def test_create_api_nopayload(): headers = {'content-type': 'application/json'} service_url_upload = setup.get_api_url("insert") response = setup.send_post_request(service_url_upload, headers) assert response.status_code == 400