kpsul/cof/tests.py
Martin Pépin 8895024a23 Fix COF membership unittest
We did not reload the right user from the database
2017-10-30 12:45:04 +01:00

26 lines
754 B
Python

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