Exemple #1
0
def get_user_groups(username):
    """
    Get the information of a user from our userdatamodel database.

    Returns a json object
    """
    return jsonify(admin.get_user_groups(current_session, username))
def test_get_user_groups(db_session, awg_users):
    groups = adm.get_user_groups(db_session, "awg_user")
    expected_groups = [
        {
            "name": "test_group_2",
            "description": "the second test group",
            "projects": ["test_project_1", "test_project_2"],
        },
        {
            "name": "test_group_1",
            "description": "the first test group",
            "projects": ["test_project_1"],
        },
    ]
    expected_groups.sort(key=lambda x: x["name"])
    groups["groups"].sort(key=lambda x: x["name"])
    assert groups["groups"] == expected_groups