Fix COF membership unittest

We did not reload the right user from the database
This commit is contained in:
Martin Pépin 2017-10-30 12:45:04 +01:00
parent 14fa40c1ff
commit 8895024a23

View file

@ -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'))