Example #1
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(TestWizardClass):
            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": {
                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
                }[pickle.HIGHEST_PROTOCOL],
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Example #2
0
    def test_14498(self):
        """
        Regression test for ticket #14498.  All previous steps' forms should be
        validated.
        """
        reached = [False]
        that = self

        class WizardWithProcessStep(TestWizardClass):
            def process_step(self, request, form, step):
                that.assertTrue(form.is_valid())
                reached[0] = True

        wizard = WizardWithProcessStep([WizardPageOneForm,
                                        WizardPageTwoForm,
                                        WizardPageThreeForm])
        data = {"0-field": "test",
                "1-field": "test2",
                "hash_0": {
                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
                }[pickle.HIGHEST_PROTOCOL],
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Example #3
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(TestWizardClass):
            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": {
                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
                }[pickle.HIGHEST_PROTOCOL],
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Example #4
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(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": {
                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
                }[pickle.HIGHEST_PROTOCOL],
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])

        data = {"0-field": "test",
                "1-field": "test2",
                "hash_0": {
                    2: "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                    3: "9355d5dff22d49dbad58e46189982cec649f9f5b",
                }[pickle.HIGHEST_PROTOCOL],
                "hash_1": {
                    2: "1e6f6315da42e62f33a30640ec7e007ad3fbf1a1",
                    3: "c33142ef9d01b1beae238adf22c3c6c57328f51a",
                }[pickle.HIGHEST_PROTOCOL],
                "wizard_step": "2"}
        self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))