Commit 4feec34f authored by Robert's avatar Robert

Add test

parent 461da84e
Pipeline #1268 failed with stage
in 1 minute and 45 seconds
......@@ -4,7 +4,7 @@ from rules import add_perm, is_authenticated
from features.groups import rules as groups
from features.groups.rules import is_closed
from features.memberships.predicates import is_member, is_member_of
from features.memberships.predicates import is_member_of
from . import predicates as memberships
from django.core import mail
from django.urls import reverse
from django.test import TestCase
from core.models import PermissionToken
from features.gestalten.models import Gestalt
from features.memberships.test_mixins import MemberMixin
from . import models
TEST_EMAIL = 'test.membership@test.local'
class Membership(MemberMixin, TestCase):
def test_memberships(self):
# force membership of TEST_EMAIL
gestalt = Gestalt.objects.get_or_create_by_email(TEST_EMAIL), created_by=gestalt)
# member gets notified on group content
reverse('create-group-article', args=(,)),
{'title': 'Test', 'text': 'Test', 'public': True})
for email_obj in mail.outbox:
if[0].find(TEST_EMAIL) >= 0:
self.assertTrue([0].find(TEST_EMAIL) >= 0)
# cleanup
mail.outbox = []
# notification contains link to resign form
resign_request_url = reverse('resign-request', args=(,))
self.assertTrue(resign_request_url in email_obj.body)
# resign form renders ok
r = self.client.get(resign_request_url)
self.assertEquals(r.status_code, 200)
# resign succeeds with email address
r =, {'member': TEST_EMAIL})
# member gets email with link to resign confirmation
token = PermissionToken.objects.get(feature_key='group-resign')
resign_confirm_url = reverse('resign-confirm', args=(token.secret_key,))
self.assertEqual(len(mail.outbox), 1)
self.assertTrue(resign_confirm_url in mail.outbox[0].body)
# resign confirmation page renders ok
r = self.client.get(resign_confirm_url)
self.assertEquals(r.status_code, 200)
# resign confirmation removes membership
num_memberships = models.Membership.objects.count()
r =
self.assertEqual(models.Membership.objects.count(), num_memberships-1)
......@@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404
from django.views.generic import DeleteView, FormView
import core
from core import fields, views, views as utils_views
from core import fields, views
from core.models import PermissionToken
from core.views import PermissionMixin
from features.associations import models as associations
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment