Пример #1
0
 def get_case_data(self, row):
     data4json = self.get_data_key(row)
     if data4json == '':
         request_data = None
     else:
         request_data = OperateJson().get_data(data4json)
     return request_data
Пример #2
0
 def get_request_data(self,row):
     '''获取请求数据
     '''
     operate_json = OperateJson()
     col = self.global_val.request_data
     request_key = self.excel.get_cell(row,col)
     request_data = None
     if request_key != '':
         request_data = operate_json.get_data(request_key)
         for key in request_data:
             if not isinstance(request_data[key],str):  # 如果value不是str类型
                 request_data[key] = json.dumps(request_data[key])  # 将value转换成str类型
     return request_data
Пример #3
0
 def get_case_header(self, row, url, request_data):
     """
     :param row:
     :param url:
     :param request_data:
     :return: 若header为write,则写入cookie,返回None,若为yes则获取cookie,若为no则返回none
     """
     header_col = get_header()
     header = self.excel.get_cell_value(row, header_col)
     if header == "write":
         op_header = OperateHeader()
         op_header.write_cookies(url=url, data=request_data)
         return None
     elif header == "yes":
         op_json = OperateJson(r"../dataconfigure/cookie.json")
         value = op_json.get_data("sessionid")
         cookie = {"sessionid": value}
         return cookie
     else:
         return None
Пример #4
0
 def read_cookies(self):
     '''从json文件中读取cookies
     '''
     ope_json = OperateJson(self.cookies_file)
     cookies = ope_json.read_json()
     return cookies
Пример #5
0
 def __init__(self):
     """yaml文件中读取相关配置"""
     self.oy = OperateYaml()
     self.oj = OperateJson()
Пример #6
0
 def write_cookies(self, url, data):
     cookie_jar = self.get_cookies(url, data)
     # 转换成字典
     cookies = requests.utils.dict_from_cookiejar(cookie_jar)
     op_json = OperateJson()
     op_json.write_json(cookies)
Пример #7
0
 def get_case_expect(self, row):
     expect4json = self.get_expect_key(row)
     expect = OperateJson(r"../dataconfigure/expect.json").get_data(
         expect4json)
     return expect
 def __init__(self):
     self.gtc = GetExcelTestcases()
     self.ir = IntergrateRequest()
     self.ec = EmailConfig()
     self.oj = OperateJson()
     self.cs = CompareStr()