Exemple #1
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": "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))
Exemple #2
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])
Exemple #3
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])
Exemple #4
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": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                "wizard_step": "1"}
        if six.PY3:
            data['hash_0'] = "9355d5dff22d49dbad58e46189982cec649f9f5b"
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #5
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": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
            "wizard_step": "1",
        }
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #6
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": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #7
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])
Exemple #8
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": "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))
Exemple #9
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": u"test",
                "1-field": u"test2",
                "hash_0": u"cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                "wizard_step": u"1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])

        data = {"0-field": u"test",
                "1-field": u"test2",
                "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                "hash_1": u"1e6f6315da42e62f33a30640ec7e007ad3fbf1a1",
                "wizard_step": u"2"}
        self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))
Exemple #10
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": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #11
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])
Exemple #12
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": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
            "wizard_step": "1",
        }
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])

        data = {
            "0-field": "test",
            "1-field": "test2",
            "hash_0": "cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
            "hash_1": "1e6f6315da42e62f33a30640ec7e007ad3fbf1a1",
            "wizard_step": "2",
        }
        self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))
Exemple #13
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": "09a53d8de15fc155bad33423e1d2ee2d82484d8a",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])

        data = {"0-field": "test",
                "1-field": "test2",
                "hash_0": "09a53d8de15fc155bad33423e1d2ee2d82484d8a",
                "hash_1": "4c352938f08b0e6467bef3cda578a1d4a82edc66",
                "wizard_step": "2"}
        self.assertRaises(http.Http404, wizard, DummyRequest(POST=data))
Exemple #14
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))
Exemple #15
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": "09a53d8de15fc155bad33423e1d2ee2d82484d8a",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #16
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(hasattr(form, 'cleaned_data'))
                reached[0] = True

        wizard = WizardWithProcessStep([WizardPageOneForm,
                                        WizardPageTwoForm,
                                        WizardPageThreeForm])
        data = {"0-field": u"test",
                "1-field": u"test2",
                "hash_0": u"cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                "wizard_step": u"1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #17
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(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])
Exemple #18
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(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])
Exemple #19
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": "09a53d8de15fc155bad33423e1d2ee2d82484d8a",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #20
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": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #21
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": u"test",
                "1-field": u"test2",
                "hash_0": u"cd13b1db3e8f55174bc5745a1b1a53408d4fd1ca",
                "wizard_step": u"1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #22
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": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Exemple #23
0
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'Step %d of %d' % (step_no, step_count))

        data = self.grab_field_data(response)
        data.update(self.wizard_step_data[step_no - 1])

        return self.client.post('/wizard2/', data)

    def test_9473(self):
        response = self.client.get('/wizard2/')
        for step_no in range(1, len(self.wizard_step_data) + 1):
            response = self.check_wizard_step(response, step_no)
9f5b",
                }[pickle.HIGHEST_PROTOCOL],
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])

    def grab_field_data(self, response):
        """
        Pull the appropriate field data from the context to pass to the next wizard step
        """
        previous_fields = response.context['previous_fields']
        fields = {'wizard_step': response.context['step0']}

        def grab(m):
            fields[m.group(1)] = m.group(2)
            return ''

        self.input_re.sub(grab, previous_fields)
        return fields