When I'm testing my form with assertRedirects I get the following error message:

AssertionError: Response didn't redirect as expected: Response code was 200 
(expected 302)


Don't know what/when/where went wrong. It seems that I'm missing some crucial 
point(s).

Thanks for your pointers & your time!
Eesti


Here are the relevant lines of test.py, views.py, urls.py and the 'runserver' 
output (when I run the app):

#tests.py:
r = self.client.post(reverse('example_form'), example_form_fixture)
self.assertRedirects(r, reverse('form_redirection'))


#views.py:
def example_form_view(request):
        if request.method == 'POST':
                form = example_form(request.POST)
                if form.is_valid():
                        form.save()
                        return HttpResponseRedirect(reverse('form_redirection'))
                else:
                        form = example_form()
        return render_to_response('example_form/example_form.html', {'form': 
form})

def form_redirection_view(request):
        return render_to_response('example_form/form_redirection_page.html')


#example_form/urls.py:
urlpatterns = patterns('',
        url(r'^example_form/$', 'sandbox.example_form.views.example_form_view', 
name='example_form'),
        url(r'^form_redirection/$', 
'sandbox.example_form.views.form_redirection_view', name='form_redirection'))   


#'runserver':
Django version 1.1.1, using settings 'sandbox.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[12/Nov/2009 01:25:38] "POST /example_form/example_form/ HTTP/1.1" 302 0
[12/Nov/2009 01:25:38] "GET /example_form/form_redirection/ HTTP/1.1" 200 60



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to