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
Beispiel #2
0
def register(setup_data,url,baserequests,db):
    # 注册
    phone = setup_data['casedata']['mobilephone']
    DbOp.deleteUser(db,phone)
    yield
    # 删除注册用户
    DbOp.deleteUser(db,phone)
Beispiel #3
0
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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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)
Beispiel #8
0
def test_register_fail(fail_data, ur1, baserequests, db):
    print(f"测试数据为:{fail_data['casedata']}")
    print(f"预期结果为:{fail_data['expect']}")
    # 发送请求
    DbOp.deleteUser(db)
    r = Member.register(ur1, baserequests, fail_data['casedata'])
    # 检查结果
    assert r.json()['msg'] == fail_data['expect']['msg']
    assert r.json()['status'] == fail_data['expect']['status']
    assert r.json()['code'] == fail_data['expect']['code']
Beispiel #9
0
def test_login_pass(success_data1, ur1, db, baserequests):
    print(f"测试数据为:{success_data1['casedata']}")
    print(f"预期结果为:{success_data1['expect']}")
    phone = success_data['casedata']['mobilephone']
    # 初始化环境
    DbOp.deleteUser(db, phone)
    # 发送请求
    r = Member.register(ur1, baserequests, success_data1['casedata'])
    assert r.json()['msg'] == success_data1['expect']['msg']
    assert r.json()['status'] == success_data1['expect']['status']
    assert r.json()['code'] == success_data1['expect']['code']
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'] == '手机号码已被注册'
Beispiel #11
0
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']) == '手机号码已被注册'
Beispiel #12
0
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)
Beispiel #13
0
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'
Beispiel #14
0
def a(url, db, baserequests):
    pass_data = {'mobilephone': 18686820596, 'pwd': 123456}

    phone = pass_data['mobilephone']
    # 初始化环境,确保环境中没有影响本次执行的数据
    DbOp.deleteUser(db, phone)
    # 发送请求
    r = Member.register(url, baserequests, {
        'mobilephone': 18686820596,
        'pwd': 123456
    })

    yield
    DbOp.deleteUser(db, phone)
Beispiel #15
0
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
Beispiel #16
0
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)
Beispiel #17
0
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)
Beispiel #18
0
def test_register_pass(pass_data, url, baserquests, db):
    print(f"测试数据为:{pass_data['casedata']}")
    print(f"期望结果为:{pass_data['expect']}")
    phone = pass_data['casedata']['mobilephone']
    # 初始化环境
    DbOp.deleteUser(db, phone)
    # 发送请求
    r = Member.register(url, baserquests, pass_data['casedata']).json()
    assert r['status'] == pass_data['expect']['status']
    assert r['code'] == pass_data['expect']['code']
    assert r['msg'] == pass_data['expect']['msg']
    # 2.检查实际有没有注册成功(1、查数据库;2、获取用户列表;3、用注册的用户登录)
    r = Member.getList(url, baserquests)
    assert phone in r.text
    # 清理环境,根据手机号删除用户
    DbOp.deleteUser(db, phone)
Beispiel #19
0
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)
Beispiel #20
0
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)
Beispiel #21
0
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)
Beispiel #22
0
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_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)
Beispiel #24
0
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)
Beispiel #25
0
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, data=pass_data['casedata'])
    # print(r.text)
    # 1.检查响应结果
    assert r.json()["status"] == pass_data["expect"]["status"]
    assert r.json()["code"] == pass_data["expect"]["code"]
    assert r.json()["msg"] == pass_data["expect"]['msg']
    #2. 检查实际有没有注册(1、查数据库2.获取用户列表。3.用注册的用户登录)
    r = Member.getList(url, baserequests)
    assert phone in r.text
    #清理环境,根据手机号删除用户
    DbOp.deleteUser(db, phone)
Beispiel #26
0
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)
Beispiel #27
0
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 r.json()['msg'] == pass_data['expect']['msg']
    assert r.json()['status'] == pass_data['expect']['status']
    assert str(r.json()['code']) == pass_data['expect']['code']
    #检查实际有没有注册成功(1.查数据库 2.获取用户列表 3.用注册用户的登录

    r = Member.getList(url, baserequests)  #获取用户列表
    assert phone in str(r.json())
    assert str(phone) in r.text  #断言电话在用户列表中(同上)
    #清理环境,根据手机号删除注册用户
    DbOp.deleteUser(db, phone)
Beispiel #28
0
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)
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'])
    r = Member.register(url, baserequests, repeat_data['casedata'])
    # 1.检查响应结果
    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'])
    # 2.检查实际有没有注册成功(1.查数据库 2.获取用户列表 3. 用注册的用户登录)
    r = Member.getList(url, baserequests)
    assert str(phone) in r.text
    # 清理环境,根据手机号删除注册用户
    DbOp.deleteUser(db, phone)
def test_register_forloginfail(login_fail_data, url, db, baserequests):
    print(f"测试数据为:{login_fail_data['casedata']}")
    print(f"预期结果为为:{login_fail_data['expect']}")
    phone = login_fail_data['casedata']['mobilephone']
    # 初始化环境
    DbOp.deleteUser(db, phone)
    # 发送请求
    r = Member.register(url, baserequests, data=login_fail_data['casedata'])
    if r.json()['status'] == login_fail_data['expect']['status']:
        DbOp.deleteUser(db, phone)
        data = {"mobilephone": f"{phone}", "pwd": "ceshizhuanyong001"}
        baserequests.post(url, data=data)
    yield
    DbOp.deleteUser(db, phone)