def test_admin_user_can_grant_or_remove_rdu_user_admin_rights(test_app_client, logged_in_admin_user):
    rdu_user = UserFactory(user_type=TypeOfUser.RDU_USER)
    assert not rdu_user.is_admin_user()

    resp = test_app_client.get(url_for("admin.make_admin_user", user_id=rdu_user.id), follow_redirects=True)

    assert resp.status_code == 200
    page = BeautifulSoup(resp.data.decode("utf-8"), "html.parser")
    assert (
        page.find("div", class_="eff-flash-message__body").get_text(strip=True)
        == "User %s is now an admin user" % rdu_user.email
    )

    assert rdu_user.is_admin_user()

    resp = test_app_client.get(url_for("admin.make_rdu_user", user_id=rdu_user.id), follow_redirects=True)

    assert resp.status_code == 200
    page = BeautifulSoup(resp.data.decode("utf-8"), "html.parser")
    assert (
        page.find("div", class_="eff-flash-message__body").get_text(strip=True)
        == "User %s is now a standard RDU user" % rdu_user.email
    )

    assert rdu_user.is_rdu_user()
def test_admin_user_cannot_grant_departmental_user_admin_rights(test_app_client, logged_in_admin_user):
    dept_user = UserFactory(user_type=TypeOfUser.DEPT_USER)
    assert not dept_user.is_admin_user()

    resp = test_app_client.get(url_for("admin.make_admin_user", user_id=dept_user.id), follow_redirects=True)

    assert resp.status_code == 200
    page = BeautifulSoup(resp.data.decode("utf-8"), "html.parser")
    assert page.find("div", class_="eff-flash-message__body").get_text(strip=True) == "Only RDU users can be made admin"

    assert not dept_user.is_admin_user()