From 8895024a23d513fc94222c5d33a5f027dd20a6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 30 Oct 2017 12:45:04 +0100 Subject: [PATCH] Fix COF membership unittest We did not reload the right user from the database --- cof/tests.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cof/tests.py b/cof/tests.py index 0f5a89e8..fef63080 100644 --- a/cof/tests.py +++ b/cof/tests.py @@ -1,8 +1,6 @@ -from django.contrib.auth.models import Group, Permission, User -from django.contrib.contenttypes.models import ContentType from django.test import TestCase -from cof.models import CofProfile +from cof.models import CofProfile, get_cof_assoc from gestion.tests import create_profile @@ -15,13 +13,13 @@ def create_cofprofile(username): class TestCofProfile(TestCase): def test_str(self): cofp = create_cofprofile('foo') - # XXX. should by default new CofProfiles be COF members? + + # CofProfiles are not cof members by default self.assertFalse(cofp.profile.user.has_perm('cof.member')) + # adding/removing a user from the group should impact the # permission - group = Group.objects.get(name='cof_members') + group = get_cof_assoc().members_group cofp.profile.user.groups.add(group) - cofp.save() - - cofp = CofProfile.objects.first() + cofp = CofProfile.objects.get(pk=cofp.pk) self.assertTrue(cofp.profile.user.has_perm('cof.member'))