dream
33 строки · 944.0 Байт
1import requests
2import json
3
4
5def get_input_json(fname):
6with open(fname, "r") as f:
7res = json.load(f)
8return {"dialogs": [res]}
9
10
11def test_one_step_responses():
12url = "http://0.0.0.0:8085/respond"
13
14print("test annotations")
15input_data = get_input_json("test_configs/test_annotations.json")
16for t in range(10):
17response = requests.post(url, json=input_data).json()[0]
18if any([response[0][i] for i in range(len(response[0]))]):
19print(f"success in try {t}")
20break
21if t == 9:
22assert any([response[0][i] for i in range(len(response[0]))]), print(response)
23
24print("test no annotations")
25input_data = get_input_json("test_configs/test_no_annotations.json")
26response = requests.post(url, json=input_data).json()[0]
27assert response[0][0] == "", print(response)
28
29print("SUCCESS!")
30
31
32if __name__ == "__main__":
33test_one_step_responses()
34