def test_group(client, dummy_user_as_group_manager, make_user): """Test the group detail page: /group/<groupname>""" test_users = ["testuser1", "testuser2", "testuser3"] # Add members to the group for username in test_users: make_user(username) ipa_admin.group_add_member(a_cn="dummy-group", o_user=test_users) # Add another user, but only as a membermanager make_user("testuser4") ipa_admin.group_add_member_manager(a_cn="dummy-group", o_user=["testuser4"]) result = client.get('/group/dummy-group/') assert result.status_code == 200 page = BeautifulSoup(result.data, 'html.parser') assert page.title assert page.title.string == 'dummy-group Group - noggin' title = page.select_one("div[data-section='identity'] > .col > h3") assert title.get_text(strip=True) == "dummy-group" assert title.find_next_sibling("div").get_text(strip=True) == "A dummy group" # Check the sponsors list sponsors = page.select( "div[data-section='sponsors'] .list-unstyled.row .col-lg-3.col-md-4.col-sm-6" ) assert len(sponsors) == 2, str(sponsors) assert sponsors[0].find("a")["href"] == "/user/dummy/" assert sponsors[0].find("a").get_text(strip=True) == "dummy" assert sponsors[1].find("a")["href"] == "/user/testuser4/" assert sponsors[1].find("a").get_text(strip=True) == "testuser4" # Check the members list members = page.select("div[data-section='members'] ul li") assert len(members) == len(test_users) + 1 for index, username in enumerate(["dummy"] + test_users): assert members[index].find("a")["href"] == f"/user/{username}/" assert members[index].find("a").get_text(strip=True) == username # Current user is a sponsor, there must be the corresponding add form assert len(page.select("form[action='/group/dummy-group/members/']")) == 1 assert ( page.select_one("#group-mailinglist a").get_text(strip=True) == "*****@*****.**" ) assert ( page.select_one("#group-ircchannel a").get_text(strip=True) == "irc:///freenode.net/#dummy-group" ) assert ( page.select_one("#group-urls a").get_text(strip=True) == "http://dummygroup.org" )
def dummy_user_as_group_manager(logged_in_dummy_user, dummy_group): """Make the dummy user a manager of the dummy-group group.""" ipa_admin.group_add_member("dummy-group", users="dummy") ipa_admin.group_add_member_manager("dummy-group", users="dummy") yield