Beispiel #1
0
    "deviceId": "9493427850897384",
    "userGroup": "meiju",
    "userGroupCredential": "b82063f4-d39b-4940-91c3-5b67d741b4d3"
}
yuliao1 = '{}放在哪个位置'
yuliao2 = '{}放在冰箱哪个位置'
data1 = data
data2 = data

foodname_data_path = "E:\AITEST\demo\demo_data\冰箱食材清单.xlsx"
result_path = "E:\AITEST\demo\demo_data\冰箱食材清单测试结果.xlsx"

r = Read_xls(foodname_data_path)
foodname_data = r.read_data(start_line=2)
# print(foodname_data)
new_book = r.copy_book()

# foodname=foodname_data[0][redis_case]
# yuliao1=yuliao1%foodname
# # yuliao2 = yuliao2 % foodname
# data1["currentUtterance"]=yuliao1
# result1=Request().requests(url,data1,'POST')
# print(result1)
# if result1["intent"]["intentType"]=="questionWhichRoomStore":
#     print("pass")

for i in range(len(foodname_data)):
    foodname = foodname_data[i][1]
    yuliao1 = yuliao1.format(foodname)
    yuliao2 = yuliao2.format(foodname)
    data1["currentUtterance"] = yuliao1
Beispiel #2
0
from common.T_websocket import WsSingle
from common.conf import Conf
from common.log import Logger
import Project_path
import time, pytest,allure,xlsxwriter,redis
from multiprocessing import Lock

from demo.redis import RedisLock1

conf_path= Project_path.conf_path
url=Conf(conf_path+"/ws.ini").get_value("WS","url")
audio_path=Conf(conf_path+"/ws.ini").get_value("WS","audio_path")
test_data_path= Project_path.TestData_path + "/case.xlsx"

r=Read_xls(test_data_path)
w=r.copy_book()
# redis_conn= redis.Redis(host='111.231.233.115', port=6379, password="******", db=redis_case)
now = time.strftime('%Y-%m-%d-%H-%M-%S')
result_path = Project_path.TestResult_path + now +__name__ + ".xls"

testdatas=[]
sheet_names=r.get_sheet_names()
for sheetname in sheet_names:
    sheet_data=r.read_data(sheetname,start_line=3)
    for each in sheet_data:
        each.append(sheetname)
    testdatas+=sheet_data
# writedata = WriteExcel()
# testdatas = r.read_data("002M30_36", start_line=3)
pass_num=0
faile_num=0
Beispiel #3
0
def get_expectData(product_model, path, result_path, run_num=None):
    if run_num == None:
        run_num = 1
    host = Conf(http_conf_path).get_value("HTTP", "sit")
    url = "%s/v1/auto_test/control/virtual" % host
    data = Default_data(product_model)
    queryinfo = data['query_reply']
    r = Read_xls(path)
    data_list = r.read_data(product_model, start_line=2)
    w = r.copy_book()
    for i in range(len(data_list)):
        testid = data_list[i][0]
        tdata = data_list[i][3]
        try:
            tts_list = eval(data_list[i][7])
        except:
            tts_list = []
        try:
            testdata = json.loads(tdata)
        except:
            testdata = '{' + tdata.replace('&', ',') + '}'
            try:
                testdata = json.loads(testdata)
            except Exception as e:
                print(e)
            else:
                testdata = dict(queryinfo, **testdata)
        finally:
            print(testid)
            data['text'] = data_list[i][4]
            data["query_reply"] = testdata
            n = run_num
            while n > 0:
                Response = Request().requests(url, data, "POST").json()
                tts = str(Response['data']['tts']['data'][0]['text'])
                print(tts)
                tts_list.append(tts)
                nlu = Response['data']['nlu']
                try:
                    lua = jsonpath.jsonpath(Response, "$..luaData")[0]
                except Exception as e:
                    lua = ''
                print(lua)
                if n == 1:
                    tts_list.append(tts)
                    tts_lists = list(set(tts_list))
                    print(tts_lists)
                    r.write_onlydata(w,
                                     i + 1,
                                     5,
                                     str(nlu),
                                     sheetname=product_model)
                    r.write_onlydata(w,
                                     i + 1,
                                     6,
                                     str(lua),
                                     sheetname=product_model)
                    r.write_onlydata(w,
                                     i + 1,
                                     7,
                                     str(tts_lists),
                                     sheetname=product_model)
                else:
                    tts_list.append(tts)
                n -= 1
        i += 1
    r.save_write(w, result_path)