forked from DGNum/gestioCOF
Fix COF membership unittest
We did not reload the right user from the database
This commit is contained in:
parent
14fa40c1ff
commit
8895024a23
1 changed files with 6 additions and 8 deletions
14
cof/tests.py
14
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 django.test import TestCase
|
||||||
|
|
||||||
from cof.models import CofProfile
|
from cof.models import CofProfile, get_cof_assoc
|
||||||
|
|
||||||
from gestion.tests import create_profile
|
from gestion.tests import create_profile
|
||||||
|
|
||||||
|
@ -15,13 +13,13 @@ def create_cofprofile(username):
|
||||||
class TestCofProfile(TestCase):
|
class TestCofProfile(TestCase):
|
||||||
def test_str(self):
|
def test_str(self):
|
||||||
cofp = create_cofprofile('foo')
|
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'))
|
self.assertFalse(cofp.profile.user.has_perm('cof.member'))
|
||||||
|
|
||||||
# adding/removing a user from the group should impact the
|
# adding/removing a user from the group should impact the
|
||||||
# permission
|
# permission
|
||||||
group = Group.objects.get(name='cof_members')
|
group = get_cof_assoc().members_group
|
||||||
cofp.profile.user.groups.add(group)
|
cofp.profile.user.groups.add(group)
|
||||||
cofp.save()
|
cofp = CofProfile.objects.get(pk=cofp.pk)
|
||||||
|
|
||||||
cofp = CofProfile.objects.first()
|
|
||||||
self.assertTrue(cofp.profile.user.has_perm('cof.member'))
|
self.assertTrue(cofp.profile.user.has_perm('cof.member'))
|
||||||
|
|
Loading…
Reference in a new issue