def test_register_pass(pass_data, url, db, baserequests): print(f"测试数据为:{pass_data['casedata']}") print(f"预期结果为:{pass_data['expect']}") phone = pass_data['casedata']['mobilephone'] # 初始化环境,确保环境中没有 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequests, pass_data["casedata"]) print(r.json()) # 检查结果 assert r.json()["status"] == pass_data["expect"]["status"] assert r.json()["code"] == pass_data["expect"]["code"] # 2. 检查实际有没有注册成功(1、查数据库 2、获取用户列表 3、用注册的用户列表 r = Member.getlist(url, baserequests) print(r.text) assert phone in r.text # 清理环境,根据手机号删除注册用户 DbOp.deleteUser(db, phone)
def test_register_pass(pass_data, baserequests, url, db): print(f"测试数据为:{pass_data['casedata']}") print(f"预期结果为:{pass_data['expect']}") phone = pass_data['casedata']['mobilephone'] # 初始化,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequests, pass_data['casedata']) print(r.text) # 1. 检查响应结果 assert str(r.json()['msg']) == str(pass_data['expect']['msg']) assert str(r.json()['status']) == str(pass_data['expect']['status']) assert str(r.json()['code']) == str(pass_data['expect']['code']) # 2.检查实际有没有注册成功(1.查数据库;2.获取用户列表;3.用注册) r = Member.getlist(url, baserequests) assert phone in r.text # 清理环境,根据手机删除注册用户 DbOp.deleteUser(db, phone)
def test_register_repeat(repeat_data, url, baserequests): print(f"测试数据为:{repeat_data['casedata']}") print(f"预期结果为:{repeat_data['expect']}") phone = repeat_data['casedata']['mobilephone'] # 环境初始化 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequests, repeat_data["casedata"]) # 检查结果 assert r.json()["status"] == pass_data["expect"]["status"] assert r.json()["code"] == pass_data["expect"]["code"] # 2. 检查实际有没有注册成功(1、查数据库 2、获取用户列表 3、用注册的用户列表 r = Member.getlist(url, baserequests) print(r.text) assert phone in r.text r = Member.register(url, baserequests, repeat_data["casedata"]) # 检查结果 assert r.json()["status"] == repeat_data["expect"]["status"] assert r.json()["code"] == repeat_data["expect"]["code"] # 清理环境 DbOp.deleteUser(db, phone)