2012-06-27 23:28:35 +02:00
|
|
|
from django.test import TestCase
|
|
|
|
|
2017-10-30 12:45:04 +01:00
|
|
|
from cof.models import CofProfile, get_cof_assoc
|
2017-02-11 18:48:13 +01:00
|
|
|
|
|
|
|
from gestion.tests import create_profile
|
|
|
|
|
2017-02-11 23:05:51 +01:00
|
|
|
|
2017-02-11 18:48:13 +01:00
|
|
|
def create_cofprofile(username):
|
|
|
|
p = create_profile(username)
|
|
|
|
return CofProfile.objects.create(profile=p)
|
|
|
|
|
2017-02-18 13:00:21 +01:00
|
|
|
|
2017-02-11 18:48:13 +01:00
|
|
|
class TestCofProfile(TestCase):
|
|
|
|
def test_str(self):
|
|
|
|
cofp = create_cofprofile('foo')
|
2017-10-30 12:45:04 +01:00
|
|
|
|
|
|
|
# CofProfiles are not cof members by default
|
2017-02-11 18:48:13 +01:00
|
|
|
self.assertFalse(cofp.profile.user.has_perm('cof.member'))
|
2017-10-30 12:45:04 +01:00
|
|
|
|
2017-02-11 18:48:13 +01:00
|
|
|
# adding/removing a user from the group should impact the
|
|
|
|
# permission
|
2017-10-30 12:45:04 +01:00
|
|
|
group = get_cof_assoc().members_group
|
2017-02-11 18:48:13 +01:00
|
|
|
cofp.profile.user.groups.add(group)
|
2017-10-30 12:45:04 +01:00
|
|
|
cofp = CofProfile.objects.get(pk=cofp.pk)
|
2017-02-11 18:48:13 +01:00
|
|
|
self.assertTrue(cofp.profile.user.has_perm('cof.member'))
|