def test_graph_add_member_existing(session, graph, users, groups):  # noqa

    add_member(groups["team-sre"], users["gary@a.co"], role="owner")
    add_member(groups["tech-ops"], users["gary@a.co"], role="owner")

    add_member(groups["team-infra"], users["gary@a.co"], role="owner")
    add_member(groups["team-infra"], groups["team-sre"])
    add_member(groups["team-infra"], groups["tech-ops"])

    add_member(groups["all-teams"], users["testuser@a.co"], role="owner")
    add_member(groups["all-teams"], groups["team-infra"])

    add_member(groups["team-sre"], users["zay@a.co"])
    add_member(groups["tech-ops"], users["zay@a.co"])

    session.commit()
    graph.update_from_db(session)

    assert get_users(graph, "team-sre") == set(["gary@a.co", "zay@a.co"])
    assert get_users(graph, "tech-ops") == set(["gary@a.co", "zay@a.co"])

    assert get_users(graph, "team-infra") == set(["gary@a.co", "zay@a.co"])
    assert get_users(graph, "team-infra", cutoff=1) == set(["gary@a.co"])

    assert get_users(graph, "all-teams") == set(["gary@a.co", "zay@a.co", "testuser@a.co"])
    assert get_users(graph, "all-teams", cutoff=1) == set(["testuser@a.co"])

    assert get_groups(graph, "gary@a.co") == set(["team-sre", "all-teams", "tech-ops",
            "team-infra"])
    assert get_groups(graph, "gary@a.co", cutoff=1) == set(["team-sre", "tech-ops", "team-infra"])

    assert get_groups(graph, "zay@a.co") == set(["team-sre", "all-teams", "tech-ops", "team-infra"])
    assert get_groups(graph, "zay@a.co", cutoff=1) == set(["team-sre", "tech-ops"])

    assert get_groups(graph, "testuser@a.co") == set(["all-teams"])
    assert get_groups(graph, "testuser@a.co", cutoff=1) == set(["all-teams"])
Test adding members to an existing relationship.
dataset/ETHPy150Open dropbox/grouper/tests/test_groups.py/test_graph_add_member_existing