Skip to content

Commit 653863d

Browse files
Create python_functions.py
1 parent 74f5c77 commit 653863d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

python_functions.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import requests
2+
3+
def test_api_get():
4+
resp = requests.get("https://reqres.in/api/users?page=2")
5+
assert (resp.status_code == 200), "Status code is not 200. Rather found : " + str(resp.status_code)
6+
for record in resp.json()['data']:
7+
if record['id'] == 7:
8+
if record['first_name'] == "Michael":
9+
print("Data matched!")
10+
11+
12+
def test_api_post():
13+
data = {'name': 'PRIME',
14+
'job': 'DEVOPS'}
15+
resp = requests.post(url="https://reqres.in/api/users", data=data)
16+
data = resp.json()
17+
print(data)
18+
19+
20+
test_api_get()
21+
22+
test_api_post()

0 commit comments

Comments
 (0)