from django.test import TestCase from cof.models import CofProfile, get_cof_assoc from gestion.tests import create_profile def create_cofprofile(username): p = create_profile(username) return CofProfile.objects.create(profile=p) class TestCofProfile(TestCase): def test_str(self): cofp = create_cofprofile('foo') # 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 = get_cof_assoc().members_group cofp.profile.user.groups.add(group) cofp = CofProfile.objects.get(pk=cofp.pk) self.assertTrue(cofp.profile.user.has_perm('cof.member'))