mirror of
https://github.com/ae-utbm/sith.git
synced 2026-10-30 22:29:32 +00:00
feat: User.all_groups
This commit is contained in:
1 parent
be1563f46f
commit
52759764a1
3 files changed
+22
-17
No files matched your search
@@ -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