dream

Форк
0
/
test_server.py 
33 строки · 1.1 Кб
1
import requests
2
import os
3

4
import common.test_utils as test_utils
5

6
SERVICE_NAME = os.getenv("SERVICE_NAME")
7
SERVICE_PORT = int(os.getenv("SERVICE_PORT"))
8
URL = f"http://0.0.0.0:{SERVICE_PORT}/comet"
9

10

11
def handler(requested_data):
12
    hypothesis = requests.post(URL, json={**requested_data}).json()
13
    return hypothesis
14

15

16
def run_test(handler):
17
    in_data, out_data = test_utils.get_dataset()
18
    for test_name in in_data:
19
        if test_name in SERVICE_NAME:
20
            hypothesis = handler(in_data[test_name])
21
            print(f"test name: {test_name}")
22
            is_equal_flag, msg = test_utils.compare_structs(out_data[test_name], hypothesis)
23
            if msg and len(msg.split("`")) == 5:
24
                _, ground_truth_text, _, hypothesis_text, _ = msg.split("`")
25
                is_equal_flag, ratio = test_utils.compare_text(ground_truth_text, hypothesis_text, 0.80)
26
                if not is_equal_flag:
27
                    msg = f"{msg} ratio = {ratio}"
28
            assert is_equal_flag, msg
29
            print("Success")
30

31

32
if __name__ == "__main__":
33
    run_test(handler)
34

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.