diff --git a/tests/test_to_check.txt b/tests/test_to_check.txt index 66e529d..1c65b18 100644 --- a/tests/test_to_check.txt +++ b/tests/test_to_check.txt @@ -1,19 +1,11 @@ - - -Subscribe users -==================== - -Using List Summary Subscribed users should get a 5th. button allowing them to modify their own subscription -... Mass Subscribe to List -Mass Subscribe Users +Mass Subscribe Users (within settings) ==================== Now we want to mass subscribe a few users to the list. Therefore, go to the mass subscription page. >>> url = '/settings/new_list1%40mail.example.com/mass_subscribe/' - >>> response = c.get(url) Check that everything went well by making sure the status code diff --git a/tests/tests.py b/tests/tests.py index 2b28e7c..7779e01 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -27,6 +27,10 @@ >>> from setup import setup_mm, Testobject, teardown_mm >>> testobject = setup_mm(Testobject()) +Import Translation Module to check success messages + >>> from django.utils.translation import gettext as _ + + Getting Started =============== @@ -163,6 +167,43 @@ >>> "Unsubscribe" in response.content True +Subscriptions +==================== + +Get the Subscriptions Page and check that the form was prefilled with the users E-Mail + >>> url = '/subscriptions/new_list1%40mail.example.com/subscribe' + >>> response = c.get(url) + >>> "james@example.com" in response.content + True + +Now subscribe James and Katie and check that you get redirected to List Summary which should now have an additional Button allowing to modify your user options. + + >>> response = c.post(url, + ... {"email": "james@example.com", + ... "real_name": "James Watt", + ... "name": "subscribe", + ... "fqdn_listname": "new_list1@mail.example.com"}) + >>> response = c.post(url, + ... {"email": "katie@example.com", + ... "real_name": "Katie Doe", + ... "name": "subscribe", + ... "fqdn_listname": "new_list1@mail.example.com"}) + >>> print (_('Subscribed')+' katie@example.com') in response.content + True + +The logged in user (james@example.com) can now modify his own membership using a button which is displayed in list_summary + >>> response = c.get('/lists/new_list1%40mail.example.com/') + >>> "mm_membership" in response.content + True + +Using the same subscription page we can unsubscribe as well. + >>> response = c.post('/subscriptions/new_list1%40mail.example.com/unsubscribe', + ... {"email": "katie@example.com", + ... "name": "unsubscribe", + ... "fqdn_listname": "new_list1@mail.example.com"}) + >>> print (_('Unsubscribed')+' katie@example.com') in response.content + True + Finishing Test =============== diff --git a/views.py b/views.py index 7dae322..499a54c 100644 --- a/views.py +++ b/views.py @@ -222,7 +222,8 @@ if form.is_valid(): #the form was valid so try to unsubscribe the user try: - response = the_list.unsubscribe(address=form.cleaned_data["email"]) + email = form.cleaned_data["email"] + response = the_list.unsubscribe(address=email) return render_to_response('mailman-django/lists/summary.html', {'list': the_list, 'message':_("Unsubscribed ")+ email },context_instance=RequestContext(request)) except ValueError, e: