def test_register_pass(pass_data, baserequest, url, db_info): ''' 注册成功 :param pass_data: 注册成功数据 :param baserequest: :param url: :return: ''' # 初始化环境,避免环境中已有本次测试用到的数据 MySqlOp.delete_user(db_info, pass_data['data']['mobilephone']) print(pass_data) # 下发请求 r = Member.register(baserequest, url, pass_data['data']) print(r.text) # 断言 # assert r.json()['code'] == pass_data['expect']['code'] # assert r.json()['status'] == pass_data['expect']['status'] # assert r.json()['msg'] == pass_data['expect']['msg'] # 重复的代码,出现次数多的代码,可以封装为方法,简化调用 Check.equla(r.json(), pass_data['expect'], 'code,status,msg') # 检查用户在系统中注册成功(1、该用户可以登录成功) # 2.检查数据库中查有没有这个用户 # 3. 查询类接口,比如list去查找 r = Member.list(baserequest, url) assert str(pass_data['data']['mobilephone']) in r.text # 清理环境;删除用户mobilephone MySqlOp.delete_user(db_info, pass_data['data']['mobilephone'])
def test_register_fail(fail_data, baserequest, url): ''' 注册失败的脚本 :param fail_data: :return: ''' print(fail_data) # 下发请求 # baserequest = BaseRequests r = Member.register(baserequest, url, fail_data['data']) print(r.text) print("==================================================") # 检查结果与预期结果一致 # assert r.json()['code'] == fail_data['expect']['code'] # assert r.json()['status'] == fail_data['expect']['status'] # assert r.json()['msg'] == fail_data['expect']['msg'] # 重复的代码,出现次数多的代码,可以封装为方法,简化调用 Check.equla(r.json(), fail_data['expect'], 'code,status,msg')