@pytest.mark.gen_test
def test_user_disable(session, graph, users, user_admin_perm_to_auditors, http_client, base_url):
    username = u"oliver@a.co"
    old_groups = sorted(get_groups(graph, username))

    # disable user
    fe_url = url(base_url, "/users/{}/disable".format(username))
    resp = yield http_client.fetch(fe_url, method="POST",
            headers={"X-Grouper-User": "zorkian@a.co"}, body=urlencode({}))
    assert resp.code == 200

    # enable user, PRESERVE groups
    fe_url = url(base_url, "/users/{}/enable".format(username))
    resp = yield http_client.fetch(fe_url, method="POST",
            headers={"X-Grouper-User": "zorkian@a.co"},
            body=urlencode({"preserve_membership": "true"}))
    assert resp.code == 200
    graph.update_from_db(session)
    assert old_groups == sorted(get_groups(graph, username)), 'nothing should be removed'

    # disable and enable, PURGE groups
    fe_url = url(base_url, "/users/{}/disable".format(username))
    resp = yield http_client.fetch(fe_url, method="POST",
            headers={"X-Grouper-User": "zorkian@a.co"}, body=urlencode({}))
    assert resp.code == 200

    fe_url = url(base_url, "/users/{}/enable".format(username))
    resp = yield http_client.fetch(fe_url, method="POST",
            headers={"X-Grouper-User": "zorkian@a.co"}, body=urlencode({}))
    assert resp.code == 200

    graph.update_from_db(session)
    assert len(get_groups(graph, username)) == 0, 'all group membership should be removed'
dataset/ETHPy150Open dropbox/grouper/tests/test_users.py/test_user_disable/original