def test_register_success(pass_data,url,db,baserequests): print(f"测试数据:{pass_data}") # 获取手机号码 mobile = pass_data['data']['mobilephone'] # 下发注册的请求 r = Member.register(url, baserequests, pass_data['data']) print(r.text) # 检查结果,1:检查响应与预期结果一致 assert r.json()['msg'] == pass_data['expect']['msg'] assert str(r.json()['code']) == str(pass_data['expect']['code']) assert r.json()['status'] == pass_data['expect']['status'] # 检查结果,2:检查系统中用户注册成功 # 方式1:查询用户,检查手机号在返回的结果中 r = Member.list(url,baserequests) print(r.text) # assert mobile in r.text # 方式2:从数据库中查询注册用户 # r = DbOp.query_user(db,mobile) # print(r) # assert len(r) == 1 # 清理环境:删除注册用户 DbOp.delete_user(db,mobile) # 重复注册
def register(url, baserequests, db): # 注册 phone = test_register_pass()['casedata']['mobilephone'] DbOp.deleteUser(db, phone) Member.register(url, baserequests, test_register_pass['casedata']) # 删除注册用户 DbOp.deleteUser(db, phone)
def register(setup_data, db, url, baserequests): # 注册用户 mobile = setup_data['casedata']['mobilephone'] Member.register(url, baserequests, setup_data['casedata']) yield # 删除注册用户 DbOp.delete_user(db, mobile)
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']) # 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 # 3.清理环境 根据手机号删除注册用户 DbOp.deleteUser(db,phone) # # @pytest.fixture(params=DataRead.readyaml("ZongHe\data_case\register_repeat.yaml")) # def repeat_data(request): # return request.param # # 重复注册 # def test_register_repeat(repeat_data): # pass
def register(setup_data, url, baserequests, db): # 注册 phone = setup_data['casedata']['mobilephone'] DbOp.deleteUser(db, phone) Member.register(url, baserequests, setup_data['casedata']) yield # 删除注册用户 DbOp.deleteUser(db, phone)
def register(setup_data, db, url, baserequests): # 注册用户 # 初始化环境,确保环境中没有影响本次执行的数据 phone = setup_data['casedata']['mobilephone'] DbOp.deleteUser(db, phone) Member.register(url, baserequests, setup_data['casedata']) yield # 删除注册的用户 DbOp.deleteUser(db, phone)
def register(setup_data, url, db, baserequests): # 注册 phone = setup_data['casedata']['mobilephone'] # 初始化环境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) # 发送请求 Member.register(url, baserequests, setup_data['casedata']) yield DbOp.deleteUser(db, phone)
def test_register_repeat(fail_data2, url, baserequests, db): print(f"测试数据为:{fail_data2['casedata']}") print(f"预期结果为:{fail_data2['expect']}") Member.register(url, baserequests, fail_data2['casedata']) r = Member.register(url, baserequests, fail_data2['casedata']) assert str(r.json()['msg']) == str(fail_data2['expect']['msg']) assert str(r.json()['status']) == str(fail_data2['expect']['status']) assert str(r.json()['code']) == str(fail_data2['expect']['code']) phone = fail_data2['casedata']['mobilephone'] DbOp.deleteUser(db, phone)
def register(setup_data, url, baserequestes, db): # 注册 phone = setup_data["casedata"]["mobilephone"] # 初始化环境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) # 发送请求 Member.register(url, baserequestes, setup_data['casedata']) yield # 删除用户 DbOp.deleteUser(db, phone)
def test_register_repeat(repeat_data, db, url, baserequests): print(f"测试数据为:{repeat_data['casedata']}") print(f"预期结果为:{repeat_data['except']}") phone = repeat_data['casedata']['mobilephone'] # 初始化坏境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) r = Member.register(url, baserequests, repeat_data['casedata']) assert r.json()['msg'] == repeat_data['except']['msg'] assert r.json()['status'] == repeat_data['except']['status'] assert r.json()['code'] == repeat_data['except']['code'] r1 = Member.register(url, baserequests, repeat_data['casedata']) assert r1.json()['msg'] == '手机号码已被注册'
def test_login_pass(pass_data, url, db, baserequests): print(f"测试数据为:{pass_data['casedata']}") print(f"预测结果为:{pass_data['expect']}") phone = pass_data['casedata']['mobilephone'] r = Member.login(url, baserequests, pass_data['casedata']) 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']) r = Member.getList(url, baserequests) assert str(phone) in r.text
def test_register_repeat(repeat_data, url, db, baserequests): phone = repeat_data['casedata']['mobilephone'] DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequests, repeat_data['casedata']) # 再次发送请求 r = Member.register(url, baserequests, repeat_data['casedata']) # 1.检查响应结果 assert r.json()['msg'] == repeat_data['expect']['msg'] assert r.json()['status'] == repeat_data['expect']['status'] assert str(r.json()['code']) == repeat_data['expect']['code'] DbOp.deleteUser(db, phone)
def test_register_cf(cf_data, ur1, db, baserequests): print(f"测试数据为:{cf_data['casedata']}") print(f"预期结果为:{cf_data['expect']}") phone = cf_data['casedata']['mobilephone'] # 初始化环境 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(ur1, baserequests, cf_data['casedata']) assert r.json()['msg'] == cf_data['expect']['msg'] assert r.json()['status'] == cf_data['expect']['status'] assert r.json()['code'] == cf_data['expect']['code'] r1 = Member.register(ur1, baserequests, cf_data['casedata']) assert r1.json()['msg'] == '手机号码已被注册' assert r.json()['code'] == '10001'
def test_register_repeat(repeat_data, url, db, baserequestes): print(f"测试数据:{repeat_data['casedata']}") print(f"预期结果:{repeat_data['expect']}") phone = repeat_data["casedata"]["mobilephone"] # 初始化环境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) # # # 发送请求 r = Member.register(url, baserequestes, repeat_data['casedata']) # 检查结果 assert str(r.json()['msg']) == str(repeat_data['expect']['msg']) assert str(r.json()['code']) == str(repeat_data['expect']['code']) assert str(r.json()['status']) == str(repeat_data['expect']['status']) r1 = Member.register(url, baserequestes, repeat_data['casedata']) assert str(r1.json()['msg']) == '手机号码已被注册'
def test_register_pass(path_data, db, url, baserequests): print(f"测试数据为:{path_data['casedata']}") print(f"预期结果为:{path_data['except']}") phone = path_data['casedata']['mobilephone'] # 初始化坏境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) r = Member.register(url, baserequests, path_data['casedata']) # 1.检查响应结果 assert r.json()['msg'] == path_data['except']['msg'] assert r.json()['status'] == path_data['except']['status'] assert r.json()['code'] == path_data['except']['code'] # 2.检查实际有没有被注册(1.数据库;2.获取用户列表;3.用注册的用户登录) r = Member.getList(url, baserequests) print(r.text) assert phone in r.text
def test_login(register, login_data, url, baserequestes): # 登录 # 检查登录结果 # 发送请求 r = Member.login(url, baserequestes, login_data['casedata']) print(r.text) assert str(r.json()['msg']) == str(login_data['expect']['msg'])
def test_register_repeat(url, baserequests, db, repeat_data): 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 str(r.json()['msg']) == str(repeat_data['expect']['msg']) assert str(r.json()['status']) == str(repeat_data['expect']['status']) assert str(r.json()['code']) == str(repeat_data['expect']['code']) # r = Member.getList(url, baserequests) # assert str(phone) in r.text r1 = Member.register(url, baserequests, repeat_data['casedata']) assert str(r1.json()['msg']) == '手机号码已被注册' DbOp.deleteUser(db, phone)
def test_login(register, login_data, url, baserequests): # 登录 r = Member.login(url, baserequests, login_data['casedata']) # 检查登录的结果 assert r.json()['msg'] == login_data['expect']['msg'] assert r.json()['status'] == login_data['expect']['status'] assert r.json()['code'] == login_data['expect']['code']
def test_login_fail(fail_data, url, baserequests): # 发送请求 r = Member.login(url, baserequests, fail_data['casedata']) # 检查结果 assert str(r.json()['msg']) == str(fail_data['expect']['msg']) assert str(r.json()['status']) == str(fail_data['expect']['status']) assert str(r.json()['code']) == str(fail_data['expect']['code'])
def test_login(login_data1, url, baserequests,register): print(f"测试数据为:{login_data1['casedata']}") print(f"预期结果为:{login_data1['expect']}") r = Member.login(url, baserequests, login_data1['casedata']) assert str(r.json()['msg']) == str(login_data1['expect']['msg']) assert str(r.json()['status']) == str(login_data1['expect']['status']) assert str(r.json()['code']) == str(login_data1['expect']['code'])
def test_register_pass(fail_data1, url, db, baserequests): print(f"测试数据为:{fail_data1['casedata']}") print(f"预期结果为:{fail_data1['expect']}") phone = fail_data1['casedata']['mobilephone'] DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequests, fail_data1['casedata']) # #检查响应结果 assert str(r.json()['msg']) == str(fail_data1['expect']['msg']) assert str(r.json()['status']) == str(fail_data1['expect']['status']) assert str(r.json()['code']) == str(fail_data1['expect']['code']) # 检查实际有没有注册成功 r = Member.getList(url, baserequests) assert phone in r.text # 清理环境根据手机号删除注册用户 DbOp.deleteUser(db, phone)
def test_register_pass(pass_data, url, db, baserequestes): print(f"测试数据:{pass_data['casedata']}") print(f"预期结果:{pass_data['expect']}") phone = pass_data["casedata"]["mobilephone"] # 初始化环境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequestes, pass_data['casedata']) # 检查响应结果 assert str(r.json()['msg']) == str(pass_data['expect']['msg']) assert str(r.json()['code']) == str(pass_data['expect']['code']) assert str(r.json()['status']) == str(pass_data['expect']['status']) r = Member.getList(url, baserequestes) assert phone in r.text # 清理环境,根据手机号清除注册用户 DbOp.deleteUser(db, phone)
def test_login(register, login_data, url, baserequests): # 登录 # 检查登录的结果 r = Member.login(url, baserequests, login_data['casedata']) assert str(r.json()['msg']) == str(login_data['expect']['msg']) assert str(r.json()['status']) == str(login_data['expect']['status']) assert str(r.json()['code']) == str(login_data['expect']['code'])
def test_register_fail(fail_data, url, baserequests): print(f"测试数据为:{fail_data['casedata']}") print(f"预期结果为:{fail_data['expect']}") r = Member.register(url, baserequests, fail_data['casedata']) assert str(r.json()['msg']) == str(fail_data['expect']['msg']) assert str(r.json()['status']) == str(fail_data['expect']['status']) assert str(r.json()['code']) == str(fail_data['expect']['code'])
def test_register_pass(success_data, ur1, db, baserequests): print(f"测试数据为:{success_data['casedata']}") print(f"预期结果为:{success_data['expect']}") phone = success_data['casedata']['mobilephone'] # 初始化环境 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(ur1, baserequests, success_data['casedata']) assert r.json()['msg'] == success_data['expect']['msg'] assert r.json()['status'] == success_data['expect']['status'] assert r.json()['code'] == success_data['expect']['code'] # 2.检查实际有没有被注册(1.数据库;2.获取用户列表;3.用注册的用户登录) r = Member.getList(ur1, baserequests) print(r.text) assert phone in r.text # 清理环境,根据手机号删除注册用户 DbOp.deleteUser(db, phone)
def test_register_forloginpass(login_success_data, url, db, baserequests): print(f"测试数据为:{login_success_data['casedata']}") print(f"预期结果为为:{login_success_data['expect']}") phone = login_success_data['casedata']['mobilephone'] # 初始化环境 DbOp.deleteUser(db, phone) # 发送请求 r = Member.register(url, baserequests, data=login_success_data['casedata']) # 1.检查响应结果 # assert r.json()['msg'] == success_data['expect']['msg'] assert r.json()['status'] == login_success_data['expect']['status'] assert r.json()['code'] == login_success_data['expect']['code'] # 2. 检查实际有没有注册成功(1.查数据库,2.获取用户列表 3.用注册的用户登录) r = Member.getList(url, baserequests) assert phone in r.text yield DbOp.deleteUser(db, phone)
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']) # 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_login_fail(path_data2, db, url, baserequests): print(f"测试数据为:{path_data2['casedata']}") print(f"预期结果为:{path_data2['except']}") r = Member.login(url, baserequests, path_data2['casedata']) # 1.检查响应结果 assert r.json()['msg'] == path_data2['except']['msg'] assert r.json()['status'] == path_data2['except']['status'] assert r.json()['code'] == path_data2['except']['code']
def test_register_repeat(repeat_data, url, db, baserequests): print(f"测试数据为:{repeat_data['casedata']}") print(f"预期结果:{repeat_data['expect']}") phone = repeat_data['casedata']['mobilephone'] # 初始化环境,确保环境中没有影响本次执行的数据 DbOp.deleteUser(db, phone) # 发送请求 Member.register(url, baserequests, repeat_data['casedata']) r1 = Member.register(url, baserequests, repeat_data['casedata']) # print(r.text) # 1.检查响应结果 assert r1.json()["status"] == repeat_data["expect"]["status"] assert r1.json()["code"] == repeat_data["expect"]["code"] assert r1.json()["msg"] == repeat_data["expect"]['msg'] # 清理环境,根据手机号删除用户 DbOp.deleteUser(db, phone)
def test_login_pass(pass_data, url, baserequestes): print(f"测试数据:{pass_data['casedata']}") print(f"预期结果:{pass_data['expect']}") # 发送请求 r = Member.login(url, baserequestes, pass_data['casedata']) # 检查响应结果 assert str(r.json()['msg']) == str(pass_data['expect']['msg']) assert str(r.json()['code']) == str(pass_data['expect']['code']) assert str(r.json()['status']) == str(pass_data['expect']['status'])