Skip to content

Commit e039bd9

Browse files
committed
Update JSON payload examples
1 parent 71924a0 commit e039bd9

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

examples/examples_03.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
import requests
2-
import uuid
2+
import random
33

4-
unique_number = str(uuid.uuid4()) # e.g. 5b4832b4-da4c-48b2-8512-68fb49b69de1
54

6-
7-
def create_json_object():
5+
def create_new_post_object():
86

97
return {
10-
"users": [
11-
{
12-
"user": {
13-
"id": unique_number,
14-
"name": "John Smith",
15-
"phone_1": "0612345678",
16-
"phone_2": "0992345678",
17-
}
18-
}
19-
]
8+
"name": "John Smith",
9+
"address": {
10+
"street": "Main Street",
11+
"number": random.randint(1000, 9999),
12+
"zipCode": 90210,
13+
"city": "Beverly Hills"
14+
}
2015
}
2116

2217

2318
def test_send_json_with_unique_number_check_status_code():
24-
response = requests.post("http://httpbin.org/post", json=create_json_object())
19+
response = requests.post("https://postman-echo.com/post", json=create_new_post_object())
2520
print(response.request.body)
2621
assert response.status_code == 200

0 commit comments

Comments
 (0)