Exemple #1
0
def DataConversion(filepath):
    testdata = Read_xls(filepath).read_data(start_line=2)
    # testdata1=testdata[redis_case]
    key_list = testdata[0][2:9]
    data_list = testdata[1:]
    list_datas = []
    for each in data_list:
        data = {}
        data['id'] = each[0]
        data["场景描述"] = each[1]
        # data["校验"]=each[-redis_case]
        m = len(each) // 7
        for i in range(0, m):
            if i == 0:
                list0 = each[2:9]
            else:
                list0 = each[(i - 1) * 7 + 9:7 * i + 9]
            onedata_dict = Conversion().list_dict(list0, key_list)
            data["接口%s" % (i + 1)] = onedata_dict
            i += 1
        data["期望值"] = each[-1]
        # list_datas.append(str(data))
        list_datas.append(data)
    # Logger().log("测试数据读取完毕!")
    return list_datas
def DataConversion(filepath, n=None, l=None):
    if n == None:
        n = 2
    if l == None:
        l = 8
    testdata = Read_xls(filepath).read_data(start_line=2)
    # testdata1=testdata[redis_case]
    key_list = testdata[0][n:(n + l)]
    data_list = testdata[1:]
    list_datas = []
    for each in data_list:
        data = {}
        data['id'] = each[0]
        data["场景描述"] = each[1]
        # data["校验"]=each[-redis_case]
        m = len(each) // l
        for i in range(0, m):
            if i == 0:
                list0 = each[n:(n + l)]
            else:
                list0 = each[i * l + n:(i + 1) * l + n]
            onedata_dict = Conversion().list_dict(list0, key_list)
            if onedata_dict["url"] != "":
                data["接口%s" % (i + 1)] = onedata_dict
        data["期望值"] = each[-1]
        # list_datas.append(str(data))
        list_datas.append(data)
        i += 1
    # Logger().log("测试数据读取完毕!")
    return list_datas
Exemple #3
0
product = "电压力锅"
product_model = ['POWER601']

test_path = Project_path.TestData_path + "%s自动化案例.xls" % product
conf_path = Project_path.conf_path + "ReplyInfo.ini"
result_path = Project_path.TestResult_path + "%s自动化案例_Result.xls" % product
http_conf_path = Project_path.conf_path + "http.ini"
db_path = Project_path.conf_path + "db.ini"

host = Conf(http_conf_path).get_value("HTTP", "sit")
testmode = Conf(http_conf_path).get_value("AITEST", "mode")
device_list = eval(Conf(db_path).get_value("Redis", "redis_db"))

url = "%s/v1/auto_test/control/virtual" % host

r = Read_xls(test_path)


def Label_Case(sheet_name=None):
    datalist = r.read_data(sheet_name, start_line=2)
    data = []
    if testmode == '0':
        for each in datalist:
            data.append(each)
    else:
        for each in datalist:
            if str(each[1]) in eval(testmode):
                data.append(each)
    return data

Exemple #4
0
from common.read_xls_news import Read_xls
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
Exemple #5
0
    "multiDialog": "false",
    "slotMiss": "false",
    "suite": "fridge520",
    "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]
import jsonpath  #嵌套字典取值s = jsonpath.jsonpath(dic,'$..name')

test_path = Project_path.TestData_path + "电饭煲自动化案例.xlsx"
conf_path = Project_path.conf_path + "ReplyInfo.ini"
result_path = Project_path.TestResult_path + "电饭煲远程控制-自动化案例_Result.xls"
http_conf_path = Project_path.conf_path + "http.ini"
sn_path = Project_path.conf_path + "sn.ini"

host = Conf(http_conf_path).get_value("HTTP", "sit")
testmode = Conf(http_conf_path).get_value("AITEST", "mode")
#sn_yb101=Conf(sn_path).get_value("AC","yb101")
#sn_HB=Conf(sn_path).get_value("AC","HB")
sn_ricecooker = Conf(sn_path).get_value("rice_cooker", "rice_cooker_4001XM")

r = Read_xls(test_path)
w = r.copy_book()
url = "%s/v1/auto_test/control/virtual" % host
data = {
    "version":
    "1.0",
    "text":
    "电饭煲开始煮饭 ",
    "uid":
    "6b07adb88106411fba94fe38c6754baa",
    "homeId":
    "162681",
    "device": {
        "sn": "0000EA11100000028197271200930000",
        "category": "EA",
        "modelNo": "40"
Exemple #7
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)
Exemple #8
0
from common.read_xls_news import Read_xls
from common.http_request_new import Request
from common.conf import Conf
from collections import Counter
import json, Project_path
http_conf_path = Project_path.conf_path + "http.ini"
host = Conf(http_conf_path).get_value("HTTP", "sit")
path = "E:\AITEST\\testdata\yb101远程控制-自动化案例_new3.xls"
conf_path = "E:\AITEST\conf\defaultQueryReply.ini"
r = Read_xls(path)
w = r.copy_book()
url = "%s/v1/auto_test/control/virtual" % host
result_path = "E:\AITEST\\testdata\yb101远程控制-自动化案例_new4.xls"
data_yb101_0 = json.loads(Conf(conf_path).get_value("AC", "yb101"))
data_ac = r.read_data('yb101', start_line=2)
for i in range(0, len(data_ac)):
    text = data_ac[i][4]
    if "空调" not in text:
        text = "空调" + text
        r.write_onlydata(w, i + 1, 4, text, sheetname='yb101')
r.save_write(w, result_path)
Exemple #9
0
from common.T_websocket import WsSingle
from common import traversing_path
from common.conf import Conf
from common.m_process import mprocess
import Project_path
import ssl, json
from common.read_xls_news import Read_xls
from common.changeChineseNumToArab import changeChineseNumToArab

xls = "D:\\Users\\lijq36\\Desktop\\8009.xls"
xls_new = "E:\\AITEST\\TestResult\\8009.xls"
r = Read_xls(xls)
w = r.copy_book()

ssl._create_default_https_context = ssl._create_unverified_context
conf_path = Project_path.conf_path
url = Conf(conf_path + "/ws.ini").get_value("WS", "url")
ws = WsSingle(url)
wav_path = "E:\\8009项目\\019"
wav_list = traversing_path.file_all_path(wav_path, file_type="wav")
print(wav_list)


def test(wav):
    wav_name = wav.split('.')[0].split('\\')[-1]
    a = ws.runsingle(wav)
    result = json.loads(a)
    print(wav_name, result['text'].replace(' ', ""))


if __name__ == '__main__':
Exemple #10
0
from common.T_websocket import WsSingle
from common import traversing_path
from common.conf import Conf
from common.m_process import mprocess
import Project_path
import ssl, json
from common.read_xls_news import Read_xls
from common.changeChineseNumToArab import changeChineseNumToArab

xls = "D:\\Users\\lijq36\\Desktop\\8009.xls"
xls_new = "E:\\AITEST\\TestResult\\8009.xls"
r = Read_xls(xls)
w = r.copy_book()

ssl._create_default_https_context = ssl._create_unverified_context
conf_path = Project_path.conf_path
url = Conf(conf_path + "/ws.ini").get_value("WS", "url")
ws = WsSingle(url)
wav_path = "E:\\8009项目\\test"
wav_list = traversing_path.file_all_path(wav_path, file_type="wav")
print(wav_list)


def tt(wav):
    wav_name = wav.split('.')[0].split('\\')[-1]
    wav_id = wav_name.split('_')[-1]
    a = ws.runsingle(wav)
    txt = json.loads(a)['text'].replace(' ', "")
    r.write_onlydata(w,
                     int(wav_id),
                     5,