예제 #1
0
class DependentData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.operat_excel = OperationExcel()
        self.run_method = RunMethod()
        self.get_data = GetData()

    # 通关caseID来获取该caseID的整行数据
    def get_case_line_data(self):
        rows_data = self.operat_excel.get_rows_data(self.case_id)
        return rows_data

    # 执行依赖测试。获取结果
    def run_dependent(self):
        row = self.operat_excel.get_row_number(self.case_id)
        request_data = self.get_data.get_data_for_json(row)
        # header = self.get_data.is_header(row)
        url = self.get_data.get_request_url(row)
        method = self.get_data.get_request_method(row)
        res = self.run_method.run_main(method, url, request_data)
        return res.json()

    # 根据依赖的key去获取执行依赖测试case的相应,然后返回
    def get_data_for_key(self, row):
        depend_data = self.get_data.get_depend_key(row)
        respense_data = self.run_dependent()
        json_exe = parse(depend_data)
        madle = json_exe.find(respense_data)
        data = [math.value for math in madle]
        if len(data) == 0:
            print('依赖数据异常')
            return None
        else:
            return data[0]
예제 #2
0
class RunTest:
	def __init__(self):
		self.run_method = RunMethod()
		self.data = GetData()
		self.asserts=Assert(self.data)
		self.od=OpenrationData()
		self.log=Log()
	def run_test_case(self):
		try:
			res = None
			rows_count = self.data.get_case_lines()
			for row in range(1, rows_count):
				is_run = self.data.get_is_run(row)
				if is_run:
					name = self.data.get_request_name(row)
					url = self.data.get_request_url(row)
					method = self.data.get_request_method(row)
					expect = self.data.get_expcet_data(row)
					is_update = self.data.get_is_update(row)
					header = self.data.get_is_header(row)
					depend_case = self.data.get_is_depend(row)
					if is_update:
						self.od.update_requests(row)
					if depend_case:
						self.od.replace_requests_data(depend_case,row)
					request_data = self.data.get_data_for_json(row)
					if header:
						res = self.run_method.run_main(method, url, request_data,header)
					else:
						res = self.run_method.run_main(method, url, request_data)
					self.asserts.assertIn(expect, res, row)
					self.log.test_log(name, method + '/' + url, request_data, res)
		except Exception as er:
			self.log.error_log(er)
예제 #3
0
class DependentData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excel = OperationExcel()
        self.data = GetData()

    #通过case_id 去获取该case_id的整行数据
    def get_case_line_data(self):
        rows_data = self.opara_excel.get_rows_data(self.case_id)
        return rows_data

    #执行*依赖测试,获取结果
    def run_dependent(self):
        run_method = RunMethod()
        #找到对应的行号,后续获取其他数据需要用到
        row_num = self.opera_excel.get_row_num(self.case_id)
        request_data = self.get_data_for_json(row_num)
        header = self.data.is_header(row_num)
        method = self.data.get_request_method(row_num)
        url = self.data.get_request_url(row_num)
        # 获取这些数据以便后续run_main 方法使用
        res = run_method.run_main(method, url, request_data, header)
        return json.loads(res)

    # 根据依赖的key获取执行依赖case的响应数据,然后返回 ***
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        # 依赖的返回数据一般都是给出来,去运行case里边解析拿到对应的需要的数据
        response_data = self.run_dependent()
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        # for i in madle:  ???
        # 	i.value
        return [math.value for math in madle][0]  # ???增强的for 循环
예제 #4
0
class DependdentData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excel = OperationExcel()
        self.data = GetData()

    # 通过case-id去获取该case—id的整行数据
    def get_case_line_data(self):
        rows_data = self.opera_excel.get_rows_data(self.case_id)
        return rows_data

    #执行依赖测试,获取结果
    def run_dependent(self):
        run_method = RunMethod()
        row_num = self.opera_excel.get_row_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)
        url = self.data.get_request_url(row_num)
        header = self.data.is_header(row_num)
        method = self.data.get_request_method(row_num)
        res = run_method.run_main(method, url, request_data, header)
        return res

    #根据依赖的key 去获取依赖测试case的响应,然后返回
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        response_data = self.run_dependent()
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
 def __init__(self, case_id):
     self.case_id = case_id
     self.use_excel = UseExcel()
     self.run_method = SendGetPost()
     self.data = GetData()
     self.tool = CommonTool()
     self.use_mysql = UseMySql()
예제 #6
0
class DependentData:

    def __init__(self, case_id):
        self.case_id = case_id
        self.oper_excel = OperationExcel()
        self.method = RunMethod()
        self.data = GetData()

    # 通过case_id去获取依赖case_id的整行数据
    def get_case_line_data(self):
        rows_data = self.oper_excel.get_rows_data(self.case_id)
        return rows_data

    # 执行依赖测试,获取结果
    def run_dependent(self):
        row_num = self.oper_excel.get_row_num(self.case_id)
        request_data = self.data.get_data_value(row_num)
        header = self.data.get_request_header(row_num)
        method = self.data.get_request_method(row_num)
        url = self.data.get_request_url(row_num)
        res = self.method.run_main(method, url, request_data, header, params=request_data)
        return res

    # 获取依赖字段的响应数据:通过执行依赖测试case来获取响应数据,响应中某个字段数据作为依赖key的value
    def get_value_for_key(self, row):
        # 获取依赖的返回数据key
        depend_data = self.data.get_depend_key(row)
        # 执行依赖case返回结果
        response_data = self.run_dependent()
        # print(depend_data)
        # print(response_data)

        return [match.value for match in parse(depend_data).find(response_data)][0]
예제 #7
0
class DependentData:
    """处理数据依赖的问题"""
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excle = OperateExcel()
        self.data = GetData()

    # 通过case_id去获取该case_id的整行数据
    def get_case_line_data(self):
        """根据case_id去获取该case_id的整行数据"""
        rows_data = self.opera_excle.get_rows_data(self.case_id)
        return rows_data

    # 执行依赖测试,获取结果
    def run_dependent(self):
        """执行依赖测试,获取结果"""
        run_method = RunMethod()
        row_num = self.opera_excle.get_row_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)
        header = self.data.is_header(row_num)
        method = self.data.get_request_method(row_num)
        url = self.data.get_request_url(row_num)
        res = run_method.run_main(method, url, request_data, header)
        # 需要将数据更改为json格式
        return json.loads(res)

    # 根据依赖的key去获取执行依赖测试case的响应,然后返回
    def get_data_for_key(self, row):
        """根据依赖的key去获取执行依赖测试case的响应,然后返回"""
        depent_data = self.data.get_denpent_key(row)
        response_data = self.run_dependent()
        json_exe = parse(depent_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #8
0
class DependData:
    def __init__(self, caseid):
        self.opera_excel = OperationExcel('../case/case2.xlsx', 'Sheet1')
        self.caseid = caseid
        self.data = GetData()

    # 通过casid获取整行数据
    def get_case_row_data(self):
        return self.opera_excel.get_rowbycaseid(self.caseid)

    # 执行依赖测试,获取结果
    def run_dependent(self):
        run_method = RunMethod()
        row = self.opera_excel.get_rowNumbycaseid(self.caseid)
        request_data = self.data.get_data_for_json(row)

        header = self.data.is_header(row)
        method = self.data.get_request_method(row)
        # data = self.data.get_request_data(row)
        url = self.data.get_url(row)
        # res = run_method.run_main(method,url,request_data,header)
        res = run_method.run_main(method, url, request_data)
        return json.loads(res.content)

    # 根据依赖的key去获取依赖测试case的响应,然后返回数据依赖字段的值
    def get_data_for_key(self, rowx):
        # 获取数据依赖字段的key
        depend_data = self.data.get_depend_key(rowx)
        # 执行依赖测试,获取数据依赖测试返回值
        res = self.run_dependent()
        # 通过key获取依赖测试的值
        json_exe = parse(depend_data)
        madle = json_exe.find(res)
        return [math.value for math in madle][0]
예제 #9
0
class DependData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.oper_excel = OperationExcel()
        self.data = GetData()

    # 通过case_id去获取该case_id的整行数据
    def get_case_line_data(self):
        rows_data = self.oper_excel.get_row_values(self.case_id)

    # 执行所依赖接口,获得结果
    def run_dependent(self):
        run_method = RunMethod()
        rowx = self.oper_excel.get_row_num(self.case_id)
        url = self.data.get_url(rowx)
        # header = self.data.get_header(rowx)
        request_data = self.data.get_request_for_json(rowx)
        method = self.data.get_method_type(rowx)
        res = run_method.run_main(url, method, request_data)
        return res

    # 根据excel中“依赖的返回数据”,查找前置接口运行结果的字段
    def get_data_for_key(self, rowx):
        depend_data = self.data.get_depend_respons(rowx)  # excel中依赖的返回字段
        response_data = self.run_dependent()  # 前置接口运行后的返回结果
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle]  # 返回匹配的字段值
예제 #10
0
class DependdentData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excel = OperationExcel(1, 'config/test_case.xls')
        self.data = GetData()

    # 通过case_id去获取该case_id的整行数据
    def get_case_line_data(self):
        rows_data = self.opera_excel.get_rows_data(self.case_id)
        return rows_data

    # 执行依赖测试,获取结果
    def run_dependent(self):
        run_method = RunMethod()
        row_num = self.opera_excel.get_row_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)

        # header = self.data.is_header(row_num)
        method = self.data.get_request_method(row_num)
        url = self.data.get_request_url(row_num)
        res = run_method.run_main(method, url, request_data, {'Content-Type': 'application/x-www-form-urlencoded'})
        return json.loads(res)

    # 根据依赖的key去获取执行依赖测试case的响应,然后返回
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        response_data = self.run_dependent()
        print(response_data)
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #11
0
 def __init__(self):
     unittest.TestCase.__init__(self)
     xiao_iron = 'E:/xt/xironbardepend/xironbackend/'
     self.run_method = RunMethod()
     self.data = GetData(xiao_iron + 'dataconfig/interfacebar1.xlsx', 2)
     self.send_mai = SendEmail()
     self.read_int = ReadIni()
예제 #12
0
class Test_login(unittest.TestCase):
    def setUp(self):
        # self.contain = IsContain()
        self.expect_data = GetData()
        self.login = PartnerLogin()

    def test_login(self):
        # data = {"phone": "18328207604", "code": "0000"}
        res = self.login.login()
        print(GetKeyword.format_response(res))
        # print(GetKeyword.get_value_by_keyword(res, "token"))

        # Assertion:
        expect_data = self.expect_data.get_expect_data(1)
        # if self.contain.is_contain(expect_data, res):
        #     print('Pass')
        # else:
        #     print('False')

        # code = GetKeyword.get_value_by_keyword(res, "code")
        # self.assertEqual(code, 1)
        pickupPhone = GetKeyword.get_value_by_keyword(res["data"]["partner"],
                                                      "pickupPhone")

        # print(pickupPhone, expect_data)
        # print("是什么:%s"%(type(pickupPhone)))
        try:
            self.assertEqual(pickupPhone, expect_data)
            self.expect_data.write_result(1, 'Pass')
            print('Pass')
        except AssertionError:
            self.expect_data.write_result(1, res)
            raise print('Fail')
예제 #13
0
class DependDentData:
    def __init__(self, case_id):
        self.opera_excel = OperationExcel()
        self.case_id = case_id
        self.data = GetData()

    def get_case_lines_data(self):
        rows_data = self.opera_excel.get_rows_data(self.case_id)
        return rows_data

    def run_dependdent(self):
        run_method = RunMethod()
        row = int(self.opera_excel.get_rows_num(self.case_id))
        request_data = self.data.get_data_for_json(row)
        cookie = self.data.is_cookie(row)
        method = self.data.get_request_method(row)
        url = self.data.get_url(row)
        res = run_method.run_main(method, url, request_data, cookie)
        return res

    #根据依赖的key去获取执行依赖测试case的响应,然后返回
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        response_data = self.run_dependdent()
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #14
0
class DependentData(object):
    def __init__(self, case_id):
        self.case_id = case_id
        self.op_excel = OperationExcel()
        self.data = GetData()

    def get_case_line_data(self):
        rows_data = self.op_excel.get_rows_data(self.case_id)
        return rows_data

    def run_dependent(self):
        run_method = RunMethod()
        row_num = self.op_excel.get_row_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)
        # header = self.data.get_header(row_num)
        method = self.data.get_request_method(row_num)
        url = self.data.get_url(row_num)
        res = run_method.run_main(method, url, request_data)
        return json.loads(res)

    def get_data_for_key(self, row):
        data_depend = self.data.get_data_depend(row)
        response_data = self.run_dependent()
        json_exe = parse(data_depend)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #15
0
class All_Run():
    
    def __init__(self):
        self.oper_excel = OperationExcel()
        self.oper_json = OperationJson()
        self.get_data = GetData()
        self.run = RunMethod()
        
    def go_on_run(self):
        #获取case行数
        case_lines = self.oper_excel.get_sheet_lines()
        #剔除0行(标题),循环取数据
        for i in range(1,case_lines):
            #case_id = self.get_data.get_case_id(i)
            case_url = self.get_data.get_case_url(i)
            case_runinfo = self.get_data.get_case_run(i) #case是否执行,返回值True/Flase
            case_method = self.get_data.get_case_url_method(i)
            case_header = self.get_data.get_case_header(i)
            #case_header = {'content-type': "application/json"}
            case_data = self.get_data.get_case_data_for_json(i)
            
            #print(type(case_header))
            #print(json.loads(case_header))
            #print(f"case_header:{case_header}\n")
            if case_runinfo:
                #method,url,data=None,header=None
                res = self.run.run_main(case_method,case_url, case_data, case_header)
            else:
                print(f"[info]:用例第{i}调不执行")
            return res
예제 #16
0
 def __init__(self):
     self.run = RunMethod()
     self.data = GetData()
     self.com_util = CommonUtil()
     self.send_mail = SendEmail()
     self.log = UserLog()
     self.logger = UserLog.get_log()
class DependdetData(object):
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excel = OperationExcel()
        self.data = GetData()
        self.run_method = RunMethod()

    # 通过case_id去获取该case_id的整行数据
    def get_case_line_data(self):
        row_data = self.opera_excel.get_rows_data(self.case_id)
        return row_data

    # 执行依赖case
    def run_dependent(self):
        row_num = self.opera_excel.get_row_num(
            self.case_id)  # 先要通过case_id去获取依赖case的行号啊
        method = self.data.get_request_method(row_num)
        url = self.data.get_request_url(row_num)
        data = self.data.get_data_for_json(row_num)
        header = self.data.is_header(row_num)
        res = self.run_method.run_main(method, url, data, header,
                                       params=data).json()
        # 执行依赖的时候获取响应的json数据,不然我拿不到依赖case的响应,因为我在runmain里面res没有转成json啊,嘿嘿
        return res  # json字典类型

    # 根据依赖的key去获取依赖case的响应,并返回values
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        response_data = self.run_dependent()
        #print(depend_data)
        #print(response_data)
        #print(type(response_data))
        return [
            match.value for match in parse(depend_data).find(response_data)
        ][0]
예제 #18
0
class DependdentData:
    def __init__(self, case_id):
        self.opera_excel = OperationExcel()
        self.data = GetData()
        self.case_id = case_id

    #通过case_id 获取case_id 整行数据
    def get_case_lines_data(self):
        rows_data = self.opera_excel.get_rows_data(self.case_id)
        return rows_data

    #执行依赖测试,获取结果
    def run_dependnt(self):
        run_method = RunMethod()
        row_num = self.opera_excel.get_row_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)
        request_method = self.data.get_request_method(row_num)
        request_header = self.data.get_data_header_json(row_num)
        request_url = self.data.get_request_url(row_num)
        res = run_method.run_main(request_method, request_url, request_header,
                                  request_data)
        return json.loads(res)
        # return res

    # 根据依赖的key,去获取 执行依赖case的相应 response,然后返回
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        response_data = self.run_dependnt()
        print depend_data
        print response_data
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        # aa = [madle.value for math in madle][0]
        return [madle.value for math in madle]
예제 #19
0
class GetLogininfo:
    def __init__(self, case_line):
        self.run_method = RunMethod()
        self.data = GetData()
        self.com_util = CommonUtil()
        self.case_line = case_line

    def get_logininfo(self):
        userinfolist = []
        url = self.data.request_url(self.case_line)
        print(url)
        method = self.data.get_request_method(self.case_line)
        print(method)
        op_json = OperationJson('../dataconfig/cookie.json')
        cookies = op_json.get_data('header')
        # print(cookies)
        request_data = self.data.get_data_for_json(7)
        print(request_data)
        res = self.run_method.run_main(method, url, request_data, cookies)
        # print(type(res))
        res = json.loads(res)
        # print(type(res))
        usercheck = res['info']['usercheck']
        userid = res['info']['userid']
        userinfolist = [usercheck, userid]
        # print(userinfolist)
        return userinfolist
예제 #20
0
 def __init__(self):
     self.run_method = RunMethod()
     self.data = GetData()
     self.common_util = CommonUtil()
     self.send_email = SendEmail()
     self.excel = OperationExcel()
     self.sheet_obj = self.excel.get_data()
예제 #21
0
class DependentData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excel = OpertionExcel()
        self.run = RunMethod()
        self.data = GetData()

    #通过case_id去获得该case_id的数据
    def get_case_line_data(self):
        rows_data = self.opera_excel.get_rows_data(self.case_id)
        return rows_data

    #执行依赖测试获取的数据
    def run_dependent(self):
        row_num = self.opera_excel.get_rows_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)
        url = self.data.get_url(row_num)
        method = self.data.get_request_way(row_num)
        header = self.data.is_header(row_num)
        #method,url,data=None,header=None
        run_depen = self.run.run_main(method, url, request_data, header)
        return json.loads(run_depen)

    #根据依赖的key去获取执行依赖测试case的响应,然后返回
    def get_data_for_key(self, rowx):
        depend_data = self.data.get_dependent_data(rowx)
        response_data = self.run_dependent()
        # print(depend_data)
        # print(response_data)
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #22
0
 def __init__(self):
     self.run_method = SendGetPost()
     self.data = GetData()
     self.tool = CommonTool()
     self.send_mail = SendEmail()
     self.use_mysql = UseMySql()
     self.excel = UseExcel()
예제 #23
0
class RunTest:
    def __init__(self):
        self.run_method = RunMethod()
        self.data = GetData()
        self.com_uitl = CommonUitl()

    #程序执行的主入口
    def go_on_run(self):
        res = None
        #获取excel行数 即case个数
        rows_count = self.data.get_case_lines()
        for i in range(1, rows_count):
            url = self.data.get_url(i)
            method = self.data.get_request_method(i)
            is_run = self.data.get_is_run(i)
            data = self.data.get_data_for_json(i)
            #预期结果值
            except_data = self.data.get_except_data(i)
            #header = self.data.is_header(i)
            if is_run:
                #method,url,data=None,header=None 顺序不能错
                res = self.run_method.run_main(method, url, data)
                print res
                if self.com_uitl.is_contain(except_data, res):
                    #print "测试通过"
                    self.data.write_data(i, "pass")
                else:
                    #print "测试失败"
                    self.data.write_data(i, "fail")
예제 #24
0
class Test_PartnerShow(unittest.TestCase):
    def setUp(self):
        self.expect_data = GetData()
        self.login = PartnerLogin()
        self.show = Partnershow()

    def test_show(self):
        # data = {"phone": "18328207604", "code": "0000"}
        # token = "Bearer " + self.login.get_token(data)
        # print(token)
        # headers = {"Authorization": token}  # “token”不能加引号!!!!
        res = self.show.show()
        print(GetKeyword.format_response(res))

        # Assertion:
        expect_data = self.expect_data.get_expect_data(2)
        code = str(GetKeyword.get_value_by_keyword(res, "code"))
        # res =str(res)
        # print(type(expect_data), type(res))
        try:
            self.assertIn(code, expect_data)
            self.expect_data.write_result(2, 'Pass')
            print('Pass')
        except AssertionError:
            self.expect_data.write_result(2, res)
            raise print('Fail')
예제 #25
0
class DependentData(object):
    def __init__(self, case_id):
        self.opexcel = OperationExcel()
        self.getdata = GetData()
        self.case_id = case_id
        self.runmethod = RunMethod()

    def get_case_line_data(self):
        row_data = self.opexcel.from_case_id_get_row_data(self.case_id)
        return row_data

    def rundependent(self):
        row_num = self.opexcel.from_case_id_get_row_num(self.case_id)
        request_data = self.getdata.get_data_for_json(row_num)
        url = self.getdata.get_url(row_num)
        method = self.getdata.get_request_method(row_num)
        header = self.getdata.is_header(row_num)
        res = self.runmethod.run_main(url, method, request_data, header)
        return res

    #在依赖response中查找依赖数据
    def get_data_for_key(self, row):
        depend_data = self.getdata.get_data_depend(row)
        response_data = self.rundependent()
        print(depend_data)
        print("************************")
        print(response_data)
        p_depend_data = parse(depend_data)
        madle = p_depend_data.find(response_data)
        return [math.value for math in madle][0]
예제 #26
0
class DependentData:
    """解决数据依赖问题"""
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_excel = OperationExcel()
        self.data = GetData()
        case_value[case_id] = {}  #先创建空的字典之后存{caseid:{id1:1}}

    def get_case_line_data(self):
        """
        通过case_id去获取该case_id的整行数据
        :param case_id: 用例ID
        :return:
        """
        rows_data = self.opera_excel.get_row_data(self.case_id)
        return rows_data

    def run_dependent(self):
        """
        查询依赖caseid的响应数据并返回
        :return:
        """
        row_num = self.opera_excel.get_row_num(self.case_id)
        res = self.data.get_respond_data(row_num)
        rj = json.loads(res)
        return rj

    def get_data_for_key(self, row):
        """
        根据依赖的key去获取执行依赖case的响应然后返回
        :return:依赖字段+依赖值 [id1:3]
        """
        log_key = None
        try:
            response_data = self.run_dependent()
            depend_data = self.data.get_depend_key(row)
            log().info('开始解析依赖字段 %s', depend_data)
            depend_k_v = str_to_dict(depend_data)
            end_key = {}

            for key in depend_k_v:
                log_key = key
                if not re.search(r'\d', key):
                    key_findvalue(response_data, key)
                else:
                    r = re.compile(r'\d')
                    str = r.sub('', key)
                    key_findvalue(response_data, str)

                end_key[key] = key_values[depend_k_v[key]]
                key_values.clear()

            case_value[self.case_id].update(end_key)  #{caseid:{id1:1,id2:2}}
            log().info('依赖字段解析完成\n%s', case_value)
            return case_value

        except Exception as e:
            log().error('在%s的响应结果中没有找到依赖字段%s', self.case_id, log_key)
            return
예제 #27
0
    def __init__(self, file_name=None, sheet_id=None):

        self.oper_ini = OperationIni()
        self.oper_h = OperationHeader()
        self.run = RunMethod()
        self.data = GetData(file_name, sheet_id)
        self.vdc = OperationVDC()
        self.accept = None
예제 #28
0
 def __init__(self):
     self.run_method = RunMethod()
     self.data = GetData()
     self.com_util = CommonUtil()
     self.send_mai = SendEmail()  #不带文件发送
     self.send_email = Email()  #带文件发送
     get_user_log = UserLog()
     self.logger = get_user_log.get_log()
예제 #29
0
 def __init__(self, case_id):
     """
     初始化数据依赖类
     :param case_id: 依赖的用例id
     """
     self.case_id = case_id
     self.opera_excel = OperationExcel()
     self.data = GetData()
예제 #30
0
 def __init__(self):
     self.json_file = "/Users/mac/Desktop/测试资料/蜗牛家产品线/woniujia_cc_jiekou/woniujia_cc_jiekou_git/woniujia_cc_project/dataconfig/request_pram.json"
     self.sheet_name = "客户模块"
     self.sheet_id = 5
     self.data = GetData(self.json_file, self.sheet_name, self.sheet_id)
     self.run_method = RunMethod()
     self.util = CommonUtil()
     self.email = SendEmail()
예제 #31
0
파일: views.py 프로젝트: jack2150/rivers
def excel_date_price(request):
    """
    Export date price for a symbol
    :param request: request
    :return: render
    """
    symbol = ''
    data = []
    dates = []
    closes = []
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = ExcelDataForm(request.POST)
        # print form.is_valid()
        # check whether it's valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required
            # ...
            # redirect to a new URL:
            symbol = form.cleaned_data['symbol']
            raw_dates = form.cleaned_data['dates']

            dates = raw_dates.split()
            df_stock = GetData.get_stock_data(symbol=symbol, reindex=True)
            df_date = df_stock[df_stock.index.isin(dates)]
            # ts(df_date)

            dates = ['%s' % c.strftime('%Y-%m-%d') for c in df_date.index]
            closes = ['%.2f' % float(c) for c in df_date['close'].values]

            for d, c in zip(dates, closes):
                data.append('%s\t%s\n' % (d, c))
            data = ''.join(data)
    else:
        form = ExcelDataForm()

    title = 'Date price data'
    if symbol:
        title += ' %s' % ('<%s>' % symbol)

    template = 'base/excel_date_price/index.html'
    parameters = dict(
        site_title=title,
        title=title,
        form=form,
        symbol=symbol,
        data=data,
        closes='\n'.join(closes),
        dates='\n'.join(dates),
    )

    return render(request, template, parameters)
예제 #32
0
파일: run_test.py 프로젝트: 2lusy/learndemo
class RunTest:
    def __init__(self):
        self.run_method = RunMethod()
        self.data = GetData()
        self.com_util = CommonUtil()
        self.send_mai = SendEmail()

    # 程序执行的
    def go_on_run(self):
        res = None
        pass_count = []
        fail_count = []
        # 10  0,1,2,3
        rows_count = self.data.get_case_lines()
        for i in range(1, rows_count):
            is_run = self.data.get_is_run(i)
            if is_run:
                url = self.data.get_request_url(i)
                method = self.data.get_request_method(i)
                request_data = self.data.get_data_for_json(i)
                expect = self.data.get_expcet_data_for_mysql(i)
                header = self.data.is_header(i)
                depend_case = self.data.is_depend(i)
                if depend_case != None:
                    self.depend_data = DependdentData(depend_case)
                    # 获取的依赖响应数据
                    depend_response_data = self.depend_data.get_data_for_key(i)
                    # 获取依赖的key
                    depend_key = self.data.get_depend_field(i)
                    request_data[depend_key] = depend_response_data
                if header == 'write':
                    res = self.run_method.run_main(method, url, request_data)
                    op_header = OperationHeader(res)
                    op_header.write_cookie()

                elif header == 'yes':
                    op_json = OperetionJson('../dataconfig/cookie.json')
                    cookie = op_json.get_data('apsid')
                    cookies = {
                        'apsid': cookie
                    }
                    res = self.run_method.run_main(method, url, request_data, cookies)
                else:
                    res = self.run_method.run_main(method, url, request_data)

                if self.com_util.is_equal_dict(expect, res) == 0:
                    self.data.write_result(i, 'pass')
                    pass_count.append(i)
                else:
                    self.data.write_result(i, res)
                    fail_count.append(i)
        self.send_mai.send_main(pass_count, fail_count)
예제 #33
0
파일: run_test.py 프로젝트: 2lusy/learndemo
 def __init__(self):
     self.run_method = RunMethod()
     self.data = GetData()
     self.com_util = CommonUtil()
     self.send_mai = SendEmail()