Exemple #1
0
def test_register_pass(pass_data, baserequest, url, db_info, login_data):
    '''
    测试注册成功功能
    :param pass_data:
    :param baserequest:
    :param url:
    '''

    # 1、初始化环境:避免环境中已有本次测试用到的数据
    MysqlOP.delete_user(db_info, pass_data['data']['mobilephone'])

    # 2、调用注册方法,注册
    r = Member.register(baserequest, url, pass_data['data'])
    print(r)
    # 3、断言注册
    # 方法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']

    # 检查用户在系统中注册成功
    # 1、登录是否成功;2、数据库中查找用户;3、list接口返回值查询是否有改用户

    # 断言注册 方法2:list接口返回值查询是否有改用户

    q = Member.list(baserequest, url)
    assert pass_data['data']['mobilephone'] in q.text
Exemple #2
0
def register(pass_data, url, baserequests, db):
    # 注册
    phone = pass_data['casedata']['mobilephone']
    DbOp.deleteUser(db, phone)
    Member.register(url, baserequests, pass_data['casedata'])
    yield
    #删除注册用户
    DbOp.deleteUser(db, phone)
Exemple #3
0
def register(setup_data, url, baserequests, db):
    connent = DbOp.connent(db)
    # 注册
    phone = setup_data['casedata']['mobilephone']
    DbOp.deleteUser(connent, phone)
    Member.register(url, baserequests, setup_data['casedata'])
    yield
    # 删除
    DbOp.deleteUser(connent, phone)
    DbOp.disconnect(connent)
Exemple #4
0
def test_recharge(recharge_data,baserequest,url,db_info):
    # 初始换环境
    MysqlOP.delete_user(db_info,recharge_data['register']['mobilephone'])
    # 注册用户
    Member.register(baserequest,url,recharge_data['register'])
    # 充值
    r = Member.recharge(baserequest,url,recharge_data['data'])
    # 断言验证
    Check.equal(r.json(),recharge_data['expect'],'code,msg,status')
    # 恢复初始化环境
    MysqlOP.delete_user(db_info, recharge_data['register']['mobilephone'])
Exemple #5
0
def test_register_repeat(repet_data, url, db, baserequests):
    print(f"预测结果为: {repet_data['casedata']}")
    print(f"预测结果为: {repet_data['expect']}")
    phone = repet_data['casedata']['mobilephone']
    DbOp.deleteUser(db, phone)
    # 发送请求
    r = Member.register(url, baserequests, repet_data['casedata'])
    r = Member.register(url, baserequests, repet_data['casedata'])
    # 检查响应
    assert r.json()['msg'] == repet_data['expect']['msg']
    assert r.json()['status'] == repet_data['expect']['status']
    assert r.json()['code'] == repet_data['expect']['code']
    DbOp.deleteUser(db, phone)
def test_login_pass(register, pass_data, url, db, baserequests):
    phone = pass_data['casedata']['mobilephone']
    # 初始化环境
    DbOp.deleteUser(connent, phone)
    # 发送请求
    Member.register(url, baserequests, pass_data['casedata'])
    login = Member.login(url, baserequests, pass_data['casedata'])
    # 检查响应结果
    assert str(login.json()['msg']) == str(pass_data['expect']['msg'])
    assert str(login.json()['status']) == str(pass_data['expect']['status'])
    assert str(login.json()['code']) == str(pass_data['expect']['code'])
    # 清理环境
    DbOp.deleteUser(connent, phone)
Exemple #7
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'])
    # 检查响应的结果
    assert r.json()['code'] == pass_data['expect']['code']
    assert r.json()['msg'] == pass_data['expect']['msg']
    # 检查实际有没有注册成功,
    r = Member.getList(url, baserequests)

    # 清理环境,根据手机号删除注册用户
    DbOp.deleteUser(db,phone)
Exemple #8
0
def test_login(register,pass_data, baserequests, url, db):
    print(f"测试数据为:{pass_data['casedata']}")
    print(f"预期结果为:{pass_data['expect']}")
    phone = pass_data['casedata']['mobilephone']
    r = Member.login(url, baserequests, pass_data['casedata'])
    assert r.json()['code'] == pass_data['expect']['code']
    assert r.json()['msg'] == pass_data['expect']['msg']
Exemple #9
0
def test_login(regiter, baserequest, url, login_data):
    # 下发登录请求
    r = Member.login(baserequest, url, data=login_data['data'])
    # 检查结果
    assert r.json()['code'] == login_data['expect']['code']
    assert r.json()['status'] == login_data['expect']['status']
    assert r.json()['msg'] == login_data['expect']['msg']
Exemple #10
0
def test_login(login_data,baserequest,url,db_info):
    # 创建初始环境
    MysqlOP.delete_user(db_info, login_data['register']['mobilephone'])
    # 注册用户
    r = Member.register(baserequest,url,login_data['register'])
    # 登录
    q = Member.login(baserequest,url,login_data['data'])
    # 检查结果
    '''
    assert q.json()['code'] == login_data['expect']['code']
    assert q.json()['status'] == login_data['expect']['status']
    assert q.json()['msg'] == login_data['expect']['msg']
    '''
    Check.equal(q.json(),login_data['expect'],'code,status,msg')
    # 恢复环境
    MysqlOP.delete_user(db_info,login_data['register']['mobilephone'])
Exemple #11
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'])
    # 检查响应结果
    assert r.json()['msg'] == pass_data['expect']['msg']
    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)
    assert str(phone) in r.text
    # 清理环境、根据手机号删除注册用户
    DbOp.deleteUser(db, phone)
Exemple #12
0
def regiter(setup_data, baserequest, url, db_info):
    # 初始化环境
    MysqlOP.delete_user(db_info, setup_data['data']['mobilephone'])
    # 注册用户
    r = Member.register(baserequest, url, setup_data['data'])
    yield
    # 清理环境,删除用户
    MysqlOP.delete_user(db_info, setup_data['data']['mobilephone'])
Exemple #13
0
def test_login_fail_none(fail_none_data, url, db, baserequests):
    # 发送请求
    login = Member.login(url, baserequests, fail_none_data['casedata'])
    # 检查响应结果
    assert str(login.json()['msg']) == str(fail_none_data['expect']['msg'])
    assert str(login.json()['status']) == str(
        fail_none_data['expect']['status'])
    assert str(login.json()['code']) == str(fail_none_data['expect']['code'])
Exemple #14
0
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 r.json()['msg'] == fail_data['expect']['msg']
    assert r.json()['status'] == fail_data['expect']['status']
    assert r.json()['code'] == fail_data['expect']['code']
Exemple #15
0
def test_recharge(recharge_data, url, baserequests):
    print(f"测试数据为:{recharge_data['casedata']}")
    print(f"预测结果为:{recharge_data['expect']}")
    # 充值
    r = Member.recharge(url, baserequests, recharge_data['casedata'])
    # 检查充值结果
    assert r.json()['msg'] == recharge_data['expect']['msg']
    assert r.json()['code'] == recharge_data['expect']['code']
    assert r.json()['status'] == recharge_data['expect']['status']
Exemple #16
0
def test_register_fail(fail_data, baserequest, url):
    '''
    注册失败的脚本
    :return:
    '''
    # 下发请求
    # 校验结果
    # 打印数据 print(fail_data)

    r = Member.register(baserequest, url, fail_data['data'])

    print(r)
    # 断言
    assert r.json()['code'] == fail_data['expect']['code']
    assert r.json()['status'] == fail_data['expect']['status']
    assert r.json()['msg'] == fail_data['expect']['msg']
Exemple #17
0
def test_login(register, login_data, url, baserequests):
    # 登录
    # 检查的登录结果
    member_login = Member.login(url, baserequests, login_data['casedata'])
    assert member_login.json()['msg'] == login_data['expect']['msg']
Exemple #18
0
def test_register_fail(fail_data,url,baserequests):
    print(f"测试数据为:{fail_data['casedata']}")
    print(f"预期结果为:{fail_data['expect']}")
    r = Member.login(url, baserequests,fail_data['casedata'])
    assert r.json()['code'] == fail_data['expect']['code']
    assert r.json()['msg'] == fail_data['expect']['msg']
Exemple #19
0
def test_register_repeat(repeat_data,baserequests,url):
    print(f"测试数据为:{repeat_data['casedata']}")
    print(f"预期结果为:{repeat_data['expect']}")
    r = Member.register(url, baserequests, repeat_data['casedata'])
    assert r.json()['code'] == repeat_data['expect']['code']
    assert r.json()['msg'] == repeat_data['expect']['msg']