import random,requests
from AddStu.database import *
# 帮助方法:登录接口
def login(username,password):
username = 'hzdltest'
password = 'hzdltest'
data={'username':username,'password':password}
return data
# 帮助方法:创建学生数据
def create_random_stu():
stu_name = '张三'+str(random.randint(20, 9999))
stu_class = str(random.randint(1,10)) + '班'
stu_sex = random.choice(['男','女'])
stu_phone = str(random.randint(13000000000, 19999999999))
stu_email = stu_phone+ '@qq.com'
data = {'stu_name': stu_name, 'stu_class': stu_class, 'stu_sex': stu_sex, 'stu_phone': stu_phone, 'stu_email': stu_email}
return data
# 帮助方法:断言响应状态码和业务状态码
def assert_code(r, code1, code2):
assert r.status_code == code1
assert r.json()['status'] == code2
# 帮助方法:通过数据库断言业务数据是正确的
def assert_values(cur,data,sql):
res = execute_query(cur, sql)
# 断言数据库中的业务数据
for k in data.keys():
assert data[k] in res[0]
help_method
最新推荐文章于 2024-11-02 16:28:26 发布