Exemplo n.º 1
0
 def __init__(self, flie_excel, sheet_name):
     self.log = my_log("读取excel sheet名称")
     #判断文件是否存在
     if os.path.exists(flie_excel):
         self.flie_excel = flie_excel
         self.sheet_name = sheet_name
         self._data = list()
     else:
         raise FileNotFoundError("文件不存在")
Exemplo n.º 2
0
 def __init__(self):
     self.log = my_log("数据库日志")
     self.conn = pymysql.connect(
         host = "211.103.136.242",
         user = "******",
         password = "******",
         database = "meiduo",
         charset = "utf8",
         port = 7090
         )
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
import json
from utils.LoginUtil import my_log
import re
import subprocess
p_data = '\\${(.*)}\\$'
#日志
log = my_log()


def json_data(data):
    return json.loads(data) if data else data


#进行字段替换
def res_find(headers, cookies, data, pattern_data=p_data):
    if "${" in headers:
        pattern = re.compile(pattern_data)
        pattern.findall(data)
    if "${" in cookies:
        pattern = re.compile(pattern_data)
        pattern.findall(data)
    log.info("替换过后的值是{}".format(headers))
    return headers, cookies


# def res_find(data, pattern_data=p_data):
#     pattern = re.compile(pattern_data)
#     re_res = pattern.findall(data)
#
#     log.info("替换过后的值是{}".format(re_res))
Exemplo n.º 4
0
 def __init__(self):
     self.log = my_log("断言验证")
Exemplo n.º 5
0
# -*- coding: utf-8 -*-
from utils.RequestUtil import Request
from config.Config import Config
from utils.LoginUtil import my_log
from utils.MysqlUtil import Mysql
from utils.AssertUtil import AssertUtil
log = my_log("日志")


def login():
    log.info("登录请求")
    con = Config().yaml_url()
    url = con + "/authorizations/"
    data = {"username": "******", "password": "******"}
    req = Request()
    r = req.post(url, json=data)
    #数据验证
    # mysql = Mysql()
    # my = mysql.execute("select id,username from tb_users where username='******'")
    # body =r["body"]["user_id"]
    # assert  my["id"] ==body
    # print(my)
    print(r)
    #断言验证状态码是否相等
    ass = AssertUtil()
    # ass.assert_code(r["code"],200)
    # ass.assert_body(r["body"],"")
    #验证是否包含
    body = r["body"]
    ass.assert_in_body(body, "'username': '******', 'user_id': 1")