Загрузил(а) файлы в ''

This commit is contained in:
Калышев Ян 2023-05-19 15:31:05 +04:00
parent 410cacaf6d
commit 2b39594ba5

31
test.py Normal file
View 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")