Question

I'm trying to write tests for form wizard views django.contrib.formstools.wizard.views.CookieWizardView, and I'm not sure how to handle writing the sequential posts in the test cases:

#test_views.py
def test_wizard_pass(self):
    response = self.c.post('/wizard/url/',first_form_post_dict)
    self.assertContains(...)
    response = self.c.post('/wizard/url/',second_step_post_dict)
    self.assertRedirect(...)

I assume I need to change the second post data based on something from the first response or something to do with the cookie used for session management, I'm just not sure what.

Was it helpful?

Solution

The test cases for CookieWizardView can be found in django.contrib.formtools.tests.wizard.wizardtests.tests (line 216, view source here), including multiple sequential posts. You can study how these are implemented and implement your own test cases in a similar way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top