Пример #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(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])
Пример #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(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])
Пример #3
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))
Пример #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": "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))
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
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))
Пример #10
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": "2fdbefd4c0cad51509478fbacddf8b13", "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])
Пример #11
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))
Пример #12
0
    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])
Пример #13
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])
Пример #14
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])
Пример #15
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])
Пример #16
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])
Пример #17
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])
Пример #18
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": "2fdbefd4c0cad51509478fbacddf8b13",
                "wizard_step": "1"}
        wizard(DummyRequest(POST=data))
        self.assertTrue(reached[0])