예제 #1
0
class DeppenddentData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_execl = OperationExecl()
        self.data = GetData()

    #通过case_id去获取一行数据
    def get_case_line_data(self):
        rows_data = self.opera_execl.get_row_data(self.case_id)
        return rows_data

    #执行依赖测试,获取结果
    def run_deppendt(self):
        #找到依赖case_id----->查询到依赖的行----->依赖行的数据------>依赖行执行请求后返回的数据
        run_method = RunMethod()
        row_num = self.opera_execl.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_way(row_num)
        url = self.data.get_request_url(row_num)
        res = run_method.run_main(method, url, request_data)
        return json.loads(res)

    #根据依赖的key去获取执行依赖测试case的响应,然后返回
    def get_data_for_key(self, row):
        deppend_data = self.data.get_response_data_depend(row)
        #  deppend_data =deppend_data.encode('unicode-escape').decode('string_escape')
        response_data = self.run_deppendt()
        print deppend_data
        print type(deppend_data)
        print type(response_data)
        print response_data
        json_exe = parse(deppend_data)
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #2
0
class DependData:
    def __init__(self, case_id):
        self.case_id = case_id
        self.opera_execl = OperationExecl()
        self.data = GetData()

    def run_depend(self):
        run_method = RunMethod()

        #获取依赖行的行号,获得该行的值
        row_num = self.opera_execl.get_row_num(self.case_id)

        #header = self.data.is_header(row_num)
        request_data = self.data.get_data_for_json(row_num)
        method = self.data.get_request_way(row_num)
        url = self.data.get_url(row_num)
        res = run_method.run_main(method, url, request_data)
        print '>>>>>>>>>>>>>>>>>>>>>>>>>'
        print type(res)
        print res
        return res

    #返回的是依赖行的数据
    def get_case_line_data(self):
        row_data = self.opera_execl.get_row_data(self.case_id)
        return row_data

    def get_data_for_key(self, row):
        key_depend = self.data.get_key_depend(row)

        response_data = self.run_depend()
        json_exe = parse(key_depend)

        print type(key_depend)
        print type(response_data)
        print response_data
        madle = json_exe.find(response_data)
        return [math.value for math in madle][0]
예제 #3
0
 def __init__(self):
     self.oper_execl = OperationExecl()
예제 #4
0
class GetData:
    def __init__(self):
        self.oper_execl = OperationExecl()

    #获取case个数
    def get_case_line(self):
        return self.oper_execl.get_rows()

    #获取是否运行
    def get_is_run(self, row):
        flag = None
        col = data_config.get_run()
        is_run = self.oper_execl.get_cell_value(row, col)
        if is_run == 'yes':
            flag = True
        else:
            flag = False
        return flag

    #获取请求方式
    def get_request_way(self, row):
        col = data_config.get_run_way()
        request_way = self.oper_execl.get_cell_value(row, col)
        return request_way

    #是否携带header
    def is_header(self, row):
        col = data_config.get_header_value()
        header = self.oper_execl.get_cell_value(row, col)
        if header != '':
            return header
        else:
            return None

    #获取url
    def get_request_url(self, row):
        col = data_config.get_url()
        url = self.oper_execl.get_cell_value(row, col)
        return url

    #获取请求数据
    def get_request_data(self, row):
        col = int(data_config.get_data())
        data = self.oper_execl.get_cell_value(row, col)
        if data == '':
            return None
        return data

    #通过获取关键字拿到data数据
    def get_data_for_json(self, row):
        oper_json = OperationJson()
        request_json = oper_json.get_data(self.get_request_data(row))
        return request_json

    #获取预期结果
    def get_expect_data(self, row):
        col = int(data_config.get_expect())
        expect = self.oper_execl.get_cell_value(row, col)
        return expect

    #获取依赖数据的caseid
    def get_case_depend(self, row):
        col = int(data_config.get_case_depend())
        depend_case_id = self.oper_execl.get_cell_value(row, col)
        if depend_case_id == '':
            return None
        else:
            return depend_case_id

    #本case中依赖其他case返回的数据
    def get_response_data_depend(self, row):
        col = int(data_config.get_response_data_depend())
        depend_key = self.oper_execl.get_cell_value(row, col)
        if depend_key == "":
            return None
        else:
            return depend_key

    #判断本case中的字段名是否存在
    def is_depend(self, row):
        col = int(data_config.get_field_depend())
        data = self.oper_execl.get_cell_value(row, col)
        if data == '':
            return None
        else:
            return data

    def write_result(self, row, value):
        col = data_config.get_result()
        self.oper_execl.write_value(row, col, value)
예제 #5
0
 def __init__(self, case_id):
     self.case_id = case_id
     self.opera_execl = OperationExecl()
     self.data = GetData()
예제 #6
0
class GetData:
    def __init__(self):
        self.oper_execl = OperationExecl()

    def get_case_size(self):
        return self.oper_execl.get_rows()

    def get_url(self, row):
        col = Data_Config.get_url()
        return self.oper_execl.get_cell_value(row, col)

    def get_is_run(self, row):
        flag = None
        col = Data_Config.get_is_run()
        is_run = self.oper_execl.get_cell_value(row, col)
        if is_run == 'yes':
            flag = True
        else:
            flag = False
        return flag

    def get_request_way(self, row):

        col = Data_Config.get_request_way()
        request_way = self.oper_execl.get_cell_value(row, col)
        return request_way

    def get_header(self, row):
        col = Data_Config.get_header()
        header = self.oper_execl.get_cell_value(row, col)
        if header == '':
            header = None
        return header

    def get_case_depend(self, row):
        col = Data_Config.get_case_depend()
        case_depend = self.oper_execl.get_cell_value(row, col)
        if case_depend == '':
            return None
        else:
            return case_depend

    def get_key_depend(self, row):
        col = Data_Config.get_key_depend()
        depend_key = self.oper_execl.get_cell_value(row, col)
        if depend_key == '':
            return None
        else:
            return depend_key

    def get_field_depend(self, row):
        col = Data_Config.get_field_depend()
        field = self.oper_execl.get_cell_value(row, col)
        if field == '':
            return None
        else:
            return field

    def get_data_for_json(self, row):
        request_json = None
        oper_json = OperationJson()
        data = self.get_data(row)
        if data != None:
            request_json = oper_json.get_data(data)
        return request_json

    #返回的是data
    def get_data(self, row):
        col = Data_Config.get_data()
        data = self.oper_execl.get_cell_value(row, col)
        if data == '':
            return None
        return data

    def get_expect(self, row):
        col = Data_Config.get_expect()
        expect = self.oper_execl.get_cell_value(row, col)
        return expect

    def write_result(self, row, value):
        col = Data_Config.get_result()
        self.oper_execl.write_value(row, col, value)