-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_CheckAllUsers.py
More file actions
25 lines (24 loc) · 1.03 KB
/
test_CheckAllUsers.py
File metadata and controls
25 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import requests
import json
import jsonpath
def test_get_all_users():#Building GET Request Test Cases
URLTested = "https://gorest.co.in/public-api/users"
response = requests.get(URLTested)
print("Response: ",response) #Checking Response
print("Content: ",response.content) #Checking Content
print(response.text) #Printing Text data of Request
assert response.status_code == 200
requests.get(URLTested, verify=True)
print("Header: ",response.headers) #Loading Headers
json_response = json.loads(response.text) #Getting Response in JSON Format
print("JSON: ", json_response)
pages = jsonpath.jsonpath(json_response,'data') #Getting Total Pages
print(pages)
payload = { 'gender': 'Female'}
payload2 = { 'gender': 'Male'}
r = requests.get(URLTested, params=payload)
r2 = requests.get(URLTested, params=payload2)
print("Request with Male Payload: ", r2)
print("Request with Female Payload: ",r)
print("Female Payload Request content: ",r.content)
print("Male Payload Request content: ",r2.content)