Skip to content

Commit

Permalink
Add some missing functest coverage
Browse files Browse the repository at this point in the history
This test would have caught the bug in #9080.

The same test was already added as a unittest in #9081
  • Loading branch information
seanh committed Nov 21, 2024
1 parent 631e49b commit fb59a5b
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/functional/api/groups/members_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,23 @@ def authorization_header(auth_client) -> dict:


class TestRemoveMember:
def test_it_removes_authed_user_from_group(self, app, db_session, factories):
group = factories.Group()
group_member = factories.User()
group.memberships.append(GroupMembership(user=group_member))
token = factories.DeveloperToken(user=group_member)
def test_it(self, app, db_session, factories):
user, other_user = factories.User.create_batch(size=2)
group, other_group = factories.Group.create_batch(size=2)
db_session.add_all(
[
GroupMembership(user=user, group=group),
GroupMembership(user=user, group=other_group),
GroupMembership(user=other_user, group=group),
]
)
token = factories.DeveloperToken(user=user)
db_session.add(token)
headers = {"Authorization": "Bearer {}".format(token.value)}
db_session.commit()

app.delete("/api/groups/{}/members/me".format(group.pubid), headers=headers)

# We currently have no elegant way to check this via the API, but in a
# future version we should be able to make a GET request here for the
# group information and check it 404s
assert group_member not in group.members
assert user not in group.members
assert user in other_group.members
assert other_user in group.members

0 comments on commit fb59a5b

Please sign in to comment.