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)
    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)
示例#3
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)
    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)
    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"])
    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)
示例#7
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"])
示例#8
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)
示例#9
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)
示例#10
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)
示例#11
0
     comfirmmessages,
     name="comfirm-messages"),
 url(r"^dumpreport/(\d+)/$", generate_poll_dump_report),
 url(r"^districtreport/(\d+)/$", generate_per_district_report),
 url(r"^pulse/$", pulse, name='pulse_json'),
 url(r"^pulse/(?P<period>\w+)/$", pulse, name='pulse_json'),
 url(r"^map-cloud/$", map_cloud, name='map_cloud'),
 url(r"^upload-contacts", upload_users, name='upload_users'),
 url(r"^access/dashboards/$", access_dashboards, name='access_dashboards'),
 url(r"^assign-group", assign_group, name="assign_group"),
 url(r'^start_poll_export/(\d+)/$',
     start_poll_export,
     name="start_poll_export"),
 url(r"^backend/vumi/$", VumiBackendView.as_view(backend_name="vumi")),
 url(r"^api/v1/ureporters/registration/steps$",
     RegistrationStepsView.as_view()),
 url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)$",
     ViewUReporter.as_view(),
     name="view_ureporter_api"),
 url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/polls/current$",
     ViewCurrentPoll.as_view(),
     name="view_current_poll_api"),
 url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/poll/(?P<poll_id>\d+)/responses/$",
     SubmitPollResponses.as_view(),
     name="submit_poll_response_api"),
 url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/polls/topics$",
     PollTopicsApiView.as_view(),
     name="poll_topics_api"),
 url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/reports/$",
     SubmitReportApiView.as_view(),
     name="submit_report_api"),
示例#12
0
                                       ('', False, '', None)],
                       }, name="ureport-contact2"),
                       (r'^api/', include(v1_api.urls)),
                       url(r'^comfirm/(?P<key>.+)/$', comfirm_message_sending, name="comfirm"),
                       url(r'^comfirmmessages/(?P<key>.+)/$', comfirmmessages, name="comfirm-messages"),
                       url(r"^dumpreport/(\d+)/$", generate_poll_dump_report),
                       url(r"^districtreport/(\d+)/$", generate_per_district_report),
                       url(r"^pulse/$", pulse, name='pulse_json'),
                       url(r"^pulse/(?P<period>\w+)/$", pulse, name='pulse_json'),
                       url(r"^map-cloud/$", map_cloud, name='map_cloud'),
                       url(r"^upload-contacts", upload_users, name='upload_users'),
                       url(r"^access/dashboards/$", access_dashboards, name='access_dashboards'),
                       url(r"^assign-group", assign_group, name="assign_group"),
                       url(r'^start_poll_export/(\d+)/$', start_poll_export, name="start_poll_export"),
                       url(r"^backend/vumi/$", VumiBackendView.as_view(backend_name="vumi")),
                       url(r"^api/v1/ureporters/registration/steps$", RegistrationStepsView.as_view()),
                       url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)$", ViewUReporter.as_view(),
                           name="view_ureporter_api"),
                       url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/polls/current$",
                           ViewCurrentPoll.as_view(), name="view_current_poll_api"),
                       url(
                           r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/poll/(?P<poll_id>\d+)/responses/$",
                           SubmitPollResponses.as_view(), name="submit_poll_response_api"),
                       url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/polls/topics$",
                           PollTopicsApiView.as_view(), name="poll_topics_api"),
                       url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/reports/$",
                           SubmitReportApiView.as_view(), name="submit_report_api"),
                       url(r"^api/v1/ureporters/(?P<backend>\w+)/(?P<user_address>\+?\w+)/poll/(?P<poll_id>\d+)/summary$", PollSummary.as_view()),

)
示例#13
0
 def setUp(self):
     self.view = RegistrationStepsView()