Загрузил(а) файлы в ''
This commit is contained in:
parent
410cacaf6d
commit
2b39594ba5
31
test.py
Normal file
31
test.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
|
urls = ["client", "driver", "pickUpPoint", "car", "order"]
|
||||||
|
|
||||||
|
for name in urls:
|
||||||
|
x = json.loads(requests.get(f'http://localhost:8081/{name}').content.decode('utf-8'))
|
||||||
|
for el in x:
|
||||||
|
if (name == "car"):
|
||||||
|
el["driverId"] = el["driver"]["id"];
|
||||||
|
y = requests.post(f'http://localhost:8080/{name}WithId', json = el)
|
||||||
|
if (y.status_code == 200):
|
||||||
|
print("ok")
|
||||||
|
else:
|
||||||
|
print("error")
|
||||||
|
elif (name == "order"):
|
||||||
|
el["carId"] = el["car"]["id"];
|
||||||
|
el["clientId"] = el["client"]["id"];
|
||||||
|
el["sourcePickUpPointId"] = el["sourcePickUpPoint"]["id"];
|
||||||
|
el["destPickUpPointId"] = el["destPickUpPoint"]["id"];
|
||||||
|
y = requests.post(f'http://localhost:8080/{name}WithId', json = el)
|
||||||
|
if (y.status_code == 200):
|
||||||
|
print("ok")
|
||||||
|
else:
|
||||||
|
print("error")
|
||||||
|
else:
|
||||||
|
y = requests.post(f'http://localhost:8080/{name}WithId', json = el)
|
||||||
|
if (y.status_code == 200):
|
||||||
|
print("ok")
|
||||||
|
else:
|
||||||
|
print("error")
|
Loading…
Reference in New Issue
Block a user