70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
from faker import Faker
|
|
|
|
fk = Faker()
|
|
|
|
|
|
def get_accounts():
|
|
"""登录用例数据"""
|
|
accounts = [
|
|
{"title": "正常登录", "username": "${ENV(USERNAME)}", "password": "${ENV(PASSWORD)}",
|
|
"status_code": 200, "msg": "token"},
|
|
{"title": "密码错误", "username": "${ENV(USERNAME)}", "password": "123457",
|
|
"status_code": 400, "msg": "non_field_errors"},
|
|
{"title": "账号错误", "username": "keyou1111", "password": "${ENV(PASSWORD)}",
|
|
"status_code": 400, "msg": "non_field_errors"},
|
|
{"title": "用户名为空", "username": "", "password": "${ENV(PASSWORD)}",
|
|
"status_code": 400, "msg": "username"},
|
|
{"title": "密码为空", "username": "${ENV(USERNAME)}", "password": "",
|
|
"status_code": 400, "msg": "password"},
|
|
]
|
|
return accounts
|
|
|
|
|
|
def generate_accounts():
|
|
"""注册用例数据"""
|
|
username = "autotest" + fk.first_name()
|
|
password = fk.ean8()
|
|
email = fk.ascii_email()
|
|
accounts = [
|
|
{"title": "注册成功", "username": username, "password": password, "email": email, "password_confirm": password,
|
|
"status_code": 201, "msg": "token"},
|
|
{"title": "用户名已注册", "username": username, "password": password, "email": fk.ascii_email(),
|
|
"password_confirm": password,
|
|
"status_code": 400, "msg": "username"},
|
|
{"title": "邮箱已注册", "username": "autotest" + fk.first_name(), "password": password, "email": email,
|
|
"password_confirm": password,
|
|
"status_code": 400, "msg": "email"},
|
|
{"title": "密码与确认密码不一致", "username": "autotest" + fk.first_name(), "password": password,
|
|
"email": fk.ascii_email(),
|
|
"password_confirm": password + password,
|
|
"status_code": 400, "msg": "non_field_errors"},
|
|
]
|
|
return accounts
|
|
|
|
|
|
def str_to_int(data):
|
|
return int(data)
|
|
|
|
|
|
def generate_projects():
|
|
"""获取项目数据的用例数据"""
|
|
data = [{"title": "获取项目列表成功", "username": "${ENV(USERNAME)}", "password": "123456",
|
|
"status_code": 200, "msg": "token"}]
|
|
return data
|
|
|
|
|
|
def setup_hooks_testcase(**kwargs):
|
|
pass
|
|
|
|
|
|
def teardown_hooks_testcase(**kwargs):
|
|
pass
|
|
|
|
|
|
def setup_hooks_teststep(request, **kwargs):
|
|
pass
|
|
|
|
|
|
def teardown_hooks_teststep(request, **kwargs):
|
|
pass
|