def test_get_user_group_values(self): group1 = Group.objects.create(name="admin") group2 = Group.objects.create(name="ceo") user = User.objects.create(username="******") user.groups.add(group1, group2) policy = AccessPolicy() result = sorted(policy.get_user_group_values(user)) self.assertEqual(result, ["admin", "ceo"])
def test_get_user_group_values_empty_if_user_is_anonymous(self): user = AnonymousUser() policy = AccessPolicy() result = sorted(policy.get_user_group_values(user)) self.assertEqual(result, [])