Esempio n. 1
0
    def test_FC_F6030(self, tdata):
        deviceModel = product_model[0]
        Logger().debug("testdata:---" + str(tdata))
        rd = myRedis(redis_db=device_list[deviceModel])
        data = Default_data(deviceModel)
        test_id = tdata[0]
        test_content = tdata[2]
        data['text'] = tdata[4]
        pre_data = tdata[3]
        try:
            pre_data = json.loads(pre_data)
        except:
            pre_data = '{' + pre_data.replace('&', ',') + '}'
            try:
                pre_data = json.loads(pre_data)
            except Exception as e:
                Logger().error(e)
                raise e
        finally:
            pre_data = dict(data['query_reply'], **pre_data)
            data["query_reply"] = pre_data

        Response = Request().requests(url, data, "POST").json()
        # 校验接口是的请求成功
        try:
            jsonpath.jsonpath(Response, "$..code")[0] == '200'
        except Exception as e:
            Logger().error(e)
            raise e
        nlu = jsonpath.jsonpath(Response, "$..nlu")[0]
        tts = jsonpath.jsonpath(Response, "$..text")[0].replace(",", ",")
        mid = jsonpath.jsonpath(Response, "$..mid")[0]
        try:
            lua = jsonpath.jsonpath(Response, "$..luaData")[0]
        except:
            lua = ''
        finally:
            rd.delete(test_id)  # 清除旧缓存
            rd.push_list(tdata)
            rd.push_onlydata(test_id, str(nlu))
            rd.push_onlydata(test_id, str(lua))
            rd.push_onlydata(test_id, str(tts))
        try:
            if not str(nlu) == str(tdata[5]):
                raise Exception("NLU异常:%s!=%s" % (str(nlu), str(tdata[5])))
            if not str(lua) == str(tdata[6]):
                raise Exception("lua命令转换异常:%s!=%s" % (str(lua), str(tdata[6])))
            if not tts in eval(tdata[7]):
                raise Exception("TTS返回异常:%s not in %s" % (tts, eval(tdata[7])))
        except Exception as e:
            result = e
            Logger().error(e)
            raise e
        else:
            result = "P"
            Logger().info(u"【%s--用例%s:%s】测试通过!" %
                          (deviceModel + product, test_id, test_content))
        finally:
            rd.push_onlydata(test_id, str(result))
            rd.push_onlydata(test_id, str(mid))
Esempio n. 2
0
def redisToxls(dblist):
    for i in range(len(dblist)):
        sheet = w.creattable(redis_db[dblist[i]])
        w.write_linedata(0, header, sheet)
        r = myRedis(dblist[i])
        key_list = r.get_keys()
        for i in range(len(key_list)):
            key_value = r.read_list(key_list[i])
            w.write_linedata(i + 1, key_value, sheet)
    w.save_excel(result_path)
Esempio n. 3
0
def redisToxls(devicelist, result_path):
    w = WriteExcel()
    for i in range(len(testDevice)):
        sheet = w.creattable(testDevice[i])
        w.write_linedata(0, header, sheet)
        r = myRedis(device_list[testDevice[i]])
        key_list = r.get_keys()
        for i in range(len(key_list)):
            key_value = r.read_list(key_list[i])
            w.write_linedata(i + 1, key_value, sheet)
    w.save_excel(result_path)
Esempio n. 4
0
    def test_EC_POWER601(self, tdata):
        appoint = Appointment()
        deviceModel = product_model[0]
        Logger().debug("testdata:---" + str(tdata))
        rd = myRedis(redis_db=device_list[deviceModel])
        data = Default_data(deviceModel)
        test_id = tdata[0]
        test_content = tdata[2]
        data['text'] = tdata[4]
        pre_data = tdata[3]
        # 对预期NLU进行日期转换(如果有日期的才会用到)
        tdata[5] = appoint.run_nlu(tdata[5])

        # 查询类LUA测试时间修改
        # test_lua = eval(tdata[6])
        try:
            sign_msg = jsonpath.jsonpath(eval(tdata[6]), "$..sign_msg")[0]
        except:
            pass
        else:
            eval(tdata[6])['error']['sign_msg'] = Appointment().run_tts(
                sign_msg)
            # tdata[6] = str(test_lua)

        # 对TTS进行转换(预约有时间时用到)
        tts_list = eval(tdata[7])
        for i in range(len(tts_list)):
            tts_list[i] = appoint.run_tts(tts_list[i])
        tdata[7] = str(tts_list)

        try:
            pre_data = json.loads(pre_data)
        except:
            pre_data = '{' + pre_data.replace('&', ',') + '}'
            try:
                pre_data = json.loads(pre_data)
            except Exception as e:
                Logger().error(e)
                raise e
        finally:
            pre_data = dict(data['query_reply'], **pre_data)
            data["query_reply"] = pre_data

        Response = Request().requests(url, data, "POST").json()
        # 校验接口是的请求成功
        try:
            jsonpath.jsonpath(Response, "$..code")[0] == '200'
        except Exception as e:
            Logger().error(e)
            raise e
        nlu = jsonpath.jsonpath(Response, "$..nlu")[0]
        tts = jsonpath.jsonpath(Response, "$..text")[0].replace(",", ",")
        mid = jsonpath.jsonpath(Response, "$..mid")[0]
        try:
            lua = jsonpath.jsonpath(Response, "$..luaData")[0]
        except:
            lua = ''
        finally:
            rd.delete(test_id)  # 清除旧缓存
            rd.push_list(tdata)
            rd.push_onlydata(test_id, str(nlu))
            rd.push_onlydata(test_id, str(lua))
            rd.push_onlydata(test_id, str(tts))
        # lua校验错误时,跳过lua校验(预约时间校验出错,处理困难)
        if lua != '':
            if lua['error'] == {}:
                if not str(lua) == str(tdata[6]):
                    raise Exception("lua命令转换异常:%s!=%s" %
                                    (str(lua), str(tdata[6])))

        try:
            if not str(nlu) == str(tdata[5]):
                raise Exception("NLU异常:%s!=%s" % (str(nlu), str(tdata[5])))
            if not tts in eval(tdata[7]):
                raise Exception("TTS返回异常:%s not in %s" % (tts, eval(tdata[7])))
        except Exception as e:
            result = e
            Logger().error(e)
            raise e
        else:
            result = "P"
            Logger().info(u"【%s--用例%s:%s】测试通过!" %
                          (deviceModel + product, test_id, test_content))
        finally:
            rd.push_onlydata(test_id, str(result))
            rd.push_onlydata(test_id, str(mid))