def test_15075(self): """ Regression test for ticket #15075. Allow modifying wizard's form_list in process_step. """ reached = [False] that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): if step == 0: self.form_list[1] = WizardPageTwoAlternativeForm if step == 1: that.assertTrue( isinstance(form, WizardPageTwoAlternativeForm)) reached[0] = True wizard = WizardWithProcessStep( [WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = { "0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1" } wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])
def test_15075(self): """ Regression test for ticket #15075. Allow modifying wizard's form_list in process_step. """ reached = [False] that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): if step == 0: self.form_list[1] = WizardPageTwoAlternativeForm if step == 1: that.assertTrue(isinstance(form, WizardPageTwoAlternativeForm)) reached[0] = True wizard = WizardWithProcessStep([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])
def test_11726(self): """ Regression test for ticket #11726. Wizard should not raise Http404 when steps are added dynamically. """ reached = [False] that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): if step == 0: if self.num_steps() < 2: self.form_list.append(WizardPageTwoForm) if step == 1: that.assertTrue(isinstance(form, WizardPageTwoForm)) reached[0] = True wizard = WizardWithProcessStep([WizardPageOneForm]) data = { "0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1" } wizard(DummyRequest(POST=data)) self.assertTrue(reached[0]) data = { "0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "hash_1": "d5b434e3934cc92fee4bd2964c4ebc06f81d362d", "wizard_step": "2" } self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))
def test_11726(self): """ Regression test for ticket #11726. Wizard should not raise Http404 when steps are added dynamically. """ reached = [False] that = self class WizardWithProcessStep(TestWizardClass): def process_step(self, request, form, step): if step == 0: if self.num_steps() < 2: self.form_list.append(WizardPageTwoForm) if step == 1: that.assertTrue(isinstance(form, WizardPageTwoForm)) reached[0] = True wizard = WizardWithProcessStep([WizardPageOneForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "hash_1": "d5b434e3934cc92fee4bd2964c4ebc06f81d362d", "wizard_step": "2"} self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))
def test_step_starts_at_zero(self): """ step should be zero for the first form """ wizard = WizardClass([WizardPageOneForm, WizardPageTwoForm]) request = DummyRequest() wizard(request) self.assertEquals(0, wizard.step)
def test_step_increments(self): """ step should be incremented when we go to the next page """ wizard = WizardClass([WizardPageOneForm, WizardPageTwoForm]) request = DummyRequest(POST={"0-field":"test", "wizard_step":"0"}) response = wizard(request) self.assertEquals(1, wizard.step)
def test_step_increments(self): """ step should be incremented when we go to the next page """ wizard = WizardClass([WizardPageOneForm, WizardPageTwoForm]) request = DummyRequest(POST={"0-field": "test", "wizard_step": "0"}) response = wizard(request) self.assertEquals(1, wizard.step)
def test_14498(self): """ Regression test for ticket #14498. """ that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): that.assertTrue(hasattr(form, 'cleaned_data')) wizard = WizardWithProcessStep([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} wizard(DummyRequest(POST=data))
def test_14576(self): """ Regression test for ticket #14576. The form of the last step is not passed to the done method. """ reached = [False] that = self class Wizard(WizardClass): def done(self, request, form_list): reached[0] = True that.assertTrue(len(form_list) == 2) wizard = Wizard([WizardPageOneForm, WizardPageTwoForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "2fdbefd4c0cad51509478fbacddf8b13", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])
def test_14498(self): """ Regression test for ticket #14498. """ that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): that.assertTrue(hasattr(form, 'cleaned_data')) wizard = WizardWithProcessStep( [WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = { "0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1" } wizard(DummyRequest(POST=data))
def test_14498(self): """ Regression test for ticket #14498. """ that = self reached = [False] class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): reached[0] = True that.assertTrue(hasattr(form, 'cleaned_data')) wizard = WizardWithProcessStep([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "2fdbefd4c0cad51509478fbacddf8b13", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])
def test_14498(self): """ Regression test for ticket #14498. All previous steps' forms should be validated. """ reached = [False] that = self class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): that.assertTrue(hasattr(form, 'cleaned_data')) reached[0] = True wizard = WizardWithProcessStep([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])
def test_14498(self): """ Regression test for ticket #14498. All previous steps' forms should be validated. """ that = self reached = [False] class WizardWithProcessStep(WizardClass): def process_step(self, request, form, step): reached[0] = True that.assertTrue(hasattr(form, 'cleaned_data')) wizard = WizardWithProcessStep([WizardPageOneForm, WizardPageTwoForm, WizardPageThreeForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "2fdbefd4c0cad51509478fbacddf8b13", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])
def test_14576(self): """ Regression test for ticket #14576. The form of the last step is not passed to the done method. """ reached = [False] that = self class Wizard(WizardClass): def done(self, request, form_list): reached[0] = True that.assertTrue(len(form_list) == 2) wizard = Wizard([WizardPageOneForm, WizardPageTwoForm]) data = {"0-field": "test", "1-field": "test2", "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c", "wizard_step": "1"} wizard(DummyRequest(POST=data)) self.assertTrue(reached[0])