예제 #1
0
def test_model_creation(db: SQLAlchemy) -> None:
    from smorest_sfs.modules.users.models import User, UserInfo

    user = User.create(username="******", password="******", userinfo=UserInfo())
    db.session.commit()

    assert (
        user.nickname == "1212"
        and user.password == "1212"
        and str(user.userinfo) == "1212"
    )

    UserInfo.where(id_=user.userinfo.id_).delete()
    User.where(id_=user.id_).delete()
예제 #2
0
def get_roles(res: Dict[str, Any]) -> Set[str]:
    uids = [i["id"] for i in res["users"]]
    roles_iter = iter(
        set(r.name for r in user.roles) for user in User.where(id__in=uids).all()
    )
    return reduce(lambda x, y: x & y, roles_iter)