def test_upload_files_post_service_returns_200(): # verify=False to disable certificate validation response = requests.post(details.url(baseUrl), data=payload, headers=headers, verify=False) assert response.status_code == 200
def test_upload_files_post_service_returns_200_payload_as_json(): # prep a payload in dict format dict_payload = { "name": "FirstOne ", "size": "100", "hash": hash(details.boundary), "file": "sample1.txt" } response = requests.post(details.url(baseUrl), data=dict_payload, verify=False) assert response.status_code == 200
def test_upload_files_post_service_returns_400_bad_payload(): # Prep a bad payload - without required parameters bad_payload = details.encode_multipart_formdata({ "name": "FirstOne ", "size": "100" }) # verify=False to disable certificate validation response = requests.post(details.url(baseUrl), data=bad_payload, headers=headers, verify=False) assert response.status_code == 400
def test_get_files_service_returns_200(): # Initiate a GET request and store the response in a variable response = requests.get( details.url(baseUrl), verify=False) # verify=False to disable certificate validation assert response.status_code == 200 # assertion to validate the response status code to expected value
def test_get_files_service_returns_200_validate_response_body(): response = requests.get(details.url(baseUrl), verify=False) response_body = response.json() # Convert the response in to a Json Object assert response_body[0]["status"] == "Completed" ''' # other parameters can be validated as required
def test_files_put_service_returns_400_without_payload(): # verify=False to disable certificate validation response = requests.put(details.url(baseUrl), headers=headers, verify=False) assert response.status_code == 400
def test_upload_files_get_service_returns_500(): response = requests.get(details.url(invalid_url), verify=False) # verify=False to disable certificate validation assert response.status_code == 500 # assertion to validate the response status code to expected value
def test_files_delete_service_returns_400_no_headers(): # verify=False to disable certificate validation response = requests.delete(details.url(baseUrl), data=payload, verify=False) assert response.status_code == 400