PIbd-22_Kalyshev_SUBD/test.py

32 lines
1.1 KiB
Python

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")