def _empty(role_id):
     session = get_db_session()
     session.execute(
         "delete from role_permission where role_id={role_id}".format(
             role_id=role_id))
     session.execute("delete from user_role where role_id={role_id}".format(
         role_id=role_id))
     session.execute(
         "delete from role where id={role_id}".format(role_id=role_id))
     session.commit()
def add_test_user():
    session = get_db_session()
    user = session.query(User).filter_by(username='******').first()
    if not user:
        user = User(username='******',
                    realname="realname_test",
                    email="*****@*****.**",
                    password="******")
        session.add(user)
        session.commit()
 def _empty(device_id, apply_id=None):
     session = get_db_session()
     session.execute(
         "delete from device_apply_record where device_id={device_id}".
         format(device_id=device_id))
     session.commit()
     if apply_id:
         session.execute(
             "delete from device_apply_record where id={id}".format(
                 id=apply_id))
         session.commit()
示例#4
0
def test1_token():
    session = get_db_session()
    user = session.query(User).filter_by(username='******').first()
    if not user:
        user = User(id=2,
                    username='******',
                    realname="test1",
                    email="*****@*****.**",
                    password="******",
                    status=1)
        session.add(user)
        session.commit()
    data = {"username": "******", "password": "******"}
    return http_post(HOST + "auth/login", data).json()['data']['access_token']
def test_login_failed_disable_user(add_test_user):
    """
    已被禁用的用户无法登录
    :param add_test_user:
    :return:
    """
    session = get_db_session()
    user = session.query(User).filter_by(username='******').first()
    user.status = 0
    session.add(user)
    session.commit()
    data = {"username": "******",
            "password": "******"}
    result = http_post(login_url, data)
    assert result.json()['code'] == 2002
    assert result.json()['msg'] == "用户已被禁用"
 def _empty(id):
     session = get_db_session()
     session.execute("delete from device where id={id}".format(id=id))
     session.commit()
示例#7
0
 def _execute(sql):
     session = get_db_session()
     session.execute(sql)
     session.commit()
def delete_test_user():
    session = get_db_session()
    user = session.query(User).filter_by(username='******').first()
    if user:
        session.delete(user)
        session.commit()