Ejemplo n.º 1
0
class GetData:
    """docstring for GetData"""
    def __init__(self):
        self.opera_excel = OperationExcel()

    # 去获取excel行数,就是case的数量
    def get_case_lines(self):
        return self.opera_excel.get_lines()

    # 获取是否执行
    def get_is_run(self, row):
        col = int(data_config.get_run())
        run_model = self.opera_excel.get_cell_vaule(row, col)
        flag = None
        if run_model.lower() == 'yes':
            flag = True
        else:
            flag = False
        return flag

    # 是否携带header
    def is_header(self, row):
        col = int(data_config.get_header())
        header = self.opera_excel.get_cell_vaule(row, col)
        if header == 'yes':
            return data_config.get_header_value()
        else:
            return None

    # 获取请求方式
    def get_request_method(self, row):
        col = int(data_config.get_run_way())
        requests_method = self.opera_excel.get_cell_vaule(row, col)
        return requests_method

    # 获取url
    def get_request_url(self, row):
        col = int(data_config.get_url())
        url = self.opera_excel.get_cell_vaule(row, col)
        return url

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

    # 通过获取关键字拿到data数据
    # 获取json配置中的值
    def get_data_for_json(self, row):
        opera_json = OperationJson()
        request_data = opera_json.get_data(self.get_request_data(row))
        return request_data

    # 获取预期结果
    def get_expcet_data(self, row):
        col = int(data_config.get_expect())
        expcet = self.opera_excel.get_cell_vaule(row, col)
        if expcet == '':
            return None
        else:
            return expcet

    # 封装写入数据的方法
    def write_result(self, row, value):
        # 获取实际结果的列
        col = int(data_config.get_result())
        self.opera_excel.write_value(row, col, value)

    # 获取依赖数据的key
    def get_depend_key(self, row):
        col = int(data_config.get_data_depend())
        depent_key = self.opera_excel.get_cell_vaule(row, col)
        if depent_key == "":
            return None
        else:
            return depent_key

    # 判断是否有case依赖
    def is_depend(self, row):
        col = int(data_config.get_case_depend())
        depend_case_id = self.opera_excel.get_cell_vaule(row, col)
        if depend_case_id == "":
            return None
        else:
            return depend_case_id

    # 获取数据依赖字段
    def get_depend_field(self, row):
        col = int(data_config.get_field_depend())
        data = self.opera_excel.get_cell_vaule(row, col)
        if data == "":
            return None
        else:
            return data
Ejemplo n.º 2
0
class GetData:
    def __init__(self):
        self.opera_excel = OperationExcel()
        self.xls_config = XlsConfiger()

    #获取excel行数(case个数)
    def get_lines(self):
        return self.opera_excel.get_lines()

    #获取是否执行
    def get_isrun(self, row):
        flag = None
        col = int(self.xls_config.col_isrun())
        run_model = self.opera_excel.get_cell_value(row, col)
        if run_model == 'yes':
            flag = True
        else:
            flag = False
        return flag

    #获取项目名
    def get_proname(self, row):
        col = int(self.xls_config.col_name())
        name = self.opera_excel.get_cell_value(row, col)
        return name

    #获取本地目录
    def get_localdir(self, row):
        col = int(self.xls_config.col_localdir())
        localdir = self.opera_excel.get_cell_value(row, col)
        return localdir

    #获取ftp目录
    def get_ftpdir(self, row):
        col = int(self.xls_config.col_ftpdir())
        ftpdir = self.opera_excel.get_cell_value(row, col)
        return ftpdir

    #获取remote上war包的目录
    def get_remote_package(self, row):
        col = int(self.xls_config.col_remote_package())
        remote_package = self.opera_excel.get_cell_value(row, col)
        return remote_package

    #获取remote上config文件的目录
    def get_remote_config(self, row):
        col = int(self.xls_config.col_remote_config())
        remote_config = self.opera_excel.get_cell_value(row, col)
        return remote_config

    #获取tomcat目录
    def get_tomcatdir(self, row):
        col = int(self.xls_config.col_tomcatdir())
        tomcatdir = self.opera_excel.get_cell_value(row, col)
        return tomcatdir

    #获取war包文件名
    def get_warname(self, row):
        col = int(self.xls_config.col_warname())
        warname = self.opera_excel.get_cell_value(row, col)
        return warname

    #获取配置文件名
    def get_configname(self, row):
        col = int(self.xls_config.col_configname())
        configname = self.opera_excel.get_cell_value(row, col)
        return configname

    #获取remoteIP
    def get_remoteIP(self, row):
        col = int(self.xls_config.col_remoteIP())
        remoteIP = self.opera_excel.get_cell_value(row, col)
        return remoteIP

    #获取remoteIP
    def get_testurl(self, row):
        col = int(self.xls_config.col_testurl())
        testurl = self.opera_excel.get_cell_value(row, col)
        return testurl