mirror of
https://github.com/ae-utbm/sith.git
synced 2026-03-13 23:25:00 +00:00
feat: User.all_groups
This commit is contained in:
@@ -418,16 +418,16 @@ class TestUserIsInGroup(TestCase):
|
||||
group_in = baker.make(Group)
|
||||
self.public_user.groups.add(group_in)
|
||||
|
||||
# clear the cached property `User.cached_groups`
|
||||
self.public_user.__dict__.pop("cached_groups", None)
|
||||
# clear the cached property `User.all_groups`
|
||||
self.public_user.__dict__.pop("all_groups", None)
|
||||
# Test when the user is in the group
|
||||
with self.assertNumQueries(1):
|
||||
with self.assertNumQueries(2):
|
||||
self.public_user.is_in_group(pk=group_in.id)
|
||||
with self.assertNumQueries(0):
|
||||
self.public_user.is_in_group(pk=group_in.id)
|
||||
|
||||
group_not_in = baker.make(Group)
|
||||
self.public_user.__dict__.pop("cached_groups", None)
|
||||
self.public_user.__dict__.pop("all_groups", None)
|
||||
# Test when the user is not in the group
|
||||
with self.assertNumQueries(1):
|
||||
self.public_user.is_in_group(pk=group_not_in.id)
|
||||
|
||||
Reference in New Issue
Block a user