diff --git a/tests/tests.py b/tests/tests.py index 7f81497..ee6fc8d 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -42,17 +42,16 @@ Make sure the load was a success by checking the status code. - >>> #response.status_code + >>> response.status_code 200 -Create a New List + +Check that login is required for a couple of pages ================= +Try to access some of the admin Pages. Accessing these pages +redirects to a login page since we need admin authority to view and use them -Try to create a new list. Accessing the page to create a new list -redirects to a login page since we need admin authority to create -a new list. - - >>> response = c.get('/mailman_django/lists/new/') + >>> response = c.get('/new_domain/') Check that login required was in the HTML content of what was loaded @@ -61,4 +60,71 @@ Hence, we log in as an admin on the login page we get as a response to our call. + + >>> response = c.post('/new_domain/', + ... {"addr": "kevin@example.com", + ... "psw": "kevin"}) + + >>> print "Add a new Domain" in response.content + True + +Create a New Domain +================= +Check the content to see that we came to the create page after +logging in. + + >>> response = c.post('/new_domain/') + + >>> print "Add a new Domain" in response.content + True + +Now create a new Domain called 'mail.example.com'. + + >>> response = c.post('/new_domain/', + ... {"mail_host": "mail.example.com", + ... "web_host": "example.com", + ... "description": "doctest testing domain"}) + +Check that the new Domain exists in the list of existing domains which is above new_domain form + + >>> print "doctest testing domain" in response.content + True + + +Create a New List +================= + +Try to create a new list. + + >>> response = c.post('/lists/new/') + +Check the content to see that we came to the create page after +logging in. + + >>> print "Create a new list" in response.content + True + +Now create a new list called 'new_list'. + + >>> response = c.post('/lists/new/', + ... {"listname": "new_list", + ... "mail_host": "mail.example.com", + ... "list_owner": "kevin@example.com", + ... "list_type": "closed_discussion", + ... "description": "doctest testing domain", + ... "languages": "English (USA)"}) + +We should now end up on a success page offering what to do next. +Let's check that this was the case. + + >>> print "What would you like to do next?" in response.content + True + +Three options appear on this page. The first one is to mass subscribe +users, the second is to go to the settings page of the list just +created and the third is to create another list. +We're still logged in so go to the page where the settings can be +changed (this page also requires admin authority). + + >>> response = c.get('/settings/new_list%40example.com/',) """ diff --git a/urls.py b/urls.py index 7b2fe66..2c96a56 100644 --- a/urls.py +++ b/urls.py @@ -21,7 +21,7 @@ urlpatterns = patterns('mailman_django.views', (r'^$', 'list_index'), - url(r'^new_domain', 'new_domain', name = 'new_domain'), + url(r'^new_domain/', 'new_domain', name = 'new_domain'), url(r'^lists/$', 'list_index', name = 'list_index'), url(r'^lists/new/$', 'list_new', name = 'list_new'), url(r'^lists/logout/$', 'logout', name = 'logout'), diff --git a/views.py b/views.py index b37fd62..6019024 100644 --- a/views.py +++ b/views.py @@ -141,16 +141,16 @@ form._errors["NON_FIELD_ERRORS"]=forms.util.ErrorList() form._errors["NON_FIELD_ERRORS"].append(e) #saving settings - """settings = mailing_list.settings + settings = mailing_list.settings + """ settings["description"] = form.cleaned_data['description'] #settings["owner_address"] = form.cleaned_data['list_owner'] #TODO: Readonly #settings["???"] = form.cleaned_data['list_type'] #TODO not found in REST #settings["???"] = form.cleaned_data['languages'] #TODO not found in REST settings.save()""" try: - pass #debug - #return render_to_response('mailman-django/lists/created.html', - # {'fqdn_listname': mailing_list.info['fqdn_listname']}) + return render_to_response('mailman-django/lists/created.html', + {'fqdn_listname': settings['fqdn_listname']}) except Exception, e: return HttpResponse(e) else: @@ -273,7 +273,7 @@ return render_to_response('mailman-django/errors/generic.html', {'message': "Unexpected error:"+ str(e)}) -#@login_required #TODO +@login_required def list_settings(request, fqdn_listname = None, template = 'mailman-django/lists/settings.html'): """