Exemplo n.º 1
0
    def test_multiple_registration_scripts_default_query(self):
        registration_steps_view = RegistrationStepsView()
        expected_query = Q(slug='ureport_autoreg2') | Q(
            slug='ureport_autoreg_luo2') | Q(slug='ureport_autoreg_kdj')

        query = registration_steps_view.get_registration_scripts_query()
        self.addTypeEqualityFunc(Q, self.are_queries_equal)
        self.assertEquals(expected_query, query)
Exemplo n.º 2
0
    def test_that_an_array_of_steps_is_returned(self):
        registration_steps_view = RegistrationStepsView()
        mocked_script_1 = Mock()
        mocked_script_1.steps.all = Mock(
            return_value=["first step", "second step"])
        mocked_script_2 = Mock()
        mocked_script_2.steps.all = Mock(return_value=["third step"])

        registration_steps = registration_steps_view.get_script_steps(
            [mocked_script_1, mocked_script_2])

        self.assertItemsEqual(registration_steps,
                              ["first step", "second step", "third step"])
Exemplo n.º 3
0
    def test_multiple_registration_scripts_query_from_settings(self):
        registration_steps_view = RegistrationStepsView()
        settings.REGISTRATION_SCRIPTS = {
            "ureport_autoreg2": "en",
            "script_2": "es",
            "script_3": "de"
        }
        expected_query = Q(slug='ureport_autoreg2') | Q(slug='script_2') | Q(
            slug='script_3')

        query = registration_steps_view.get_registration_scripts_query()
        self.addTypeEqualityFunc(Q, self.are_queries_equal)
        self.assertEquals(expected_query, query)
Exemplo n.º 4
0
    def test_that_the_registration_scripts_are_called(self):
        registration_steps_view = RegistrationStepsView()
        settings.REGISTRATION_SCRIPTS = {
            "ureport_autoreg2": "en",
            "ureport_autoreg_luo2": "ach"
        }
        Script.objects.filter = Mock(side_effect=self.script_side_effect)
        registration_scripts = registration_steps_view.get_registration_scripts(
        )
        expected_script_names = [
            Script(slug='ureport_autoreg2'),
            Script(slug='ureport_autoreg_luo2')
        ]

        self.assertListEqual(expected_script_names, registration_scripts)
Exemplo n.º 5
0
    def test_that_step_string_get_the_poll_translation(self):
        registration_steps_view = RegistrationStepsView()
        settings.REGISTRATION_SCRIPTS = {
            "ureport_autoreg2": "en",
            "ureport_autoreg_luo2": "ach"
        }

        poll_step = self.get_mocked_step_with_poll_question(
            "expected question", "ureport_autoreg2")
        poll_luo_step = self.get_mocked_step_with_poll_question(
            "luo question", "ureport_autoreg_luo2")
        Translation.objects.get_or_create(field="luo question",
                                          language="ach",
                                          value="translated luo question")
        step_message = self.get_mocked_step_with_message("expected message")
        steps = [poll_step, step_message, poll_luo_step]

        steps_strings = registration_steps_view.get_step_strings(steps)

        self.assertItemsEqual([
            u'expected question', u'expected message',
            u'translated luo question'
        ], steps_strings)
Exemplo n.º 6
0
 def setUp(self):
     self.view = RegistrationStepsView()