def get_mocked_step_with_poll_question(self, question, script_slug='registration_script'):
     mocked_poll = Poll()
     mocked_poll.question = question
     poll_step = ScriptStep()
     poll_step.poll = mocked_poll
     poll_step.script = Script(slug=script_slug)
     return poll_step
Beispiel #2
0
 def get_mocked_step_with_poll_question(self,
                                        question,
                                        script_slug='registration_script'):
     mocked_poll = Poll()
     mocked_poll.question = question
     poll_step = ScriptStep()
     poll_step.poll = mocked_poll
     poll_step.script = Script(slug=script_slug)
     return poll_step
Beispiel #3
0
 def test_that_if_the_step_is_a_message_the_poll_id_is_none(self):
     message = "hello hallo who aaa"
     fake_get_next_step = Mock(return_value=ScriptStep(message=message))
     self.view.get_current_step = fake_get_next_step
     expected_data = {
         "name": "Message",
         "question": message,
         "type": "none",
         "id": None,
         "is_registration_end": False
     }
     actual_data = self.view.get_data_from_message(message)
     self.assertDictEqual(expected_data, actual_data)
Beispiel #4
0
 def test_that_script_progress_moves_on_when_current_step_is_message(self):
     self.setup_fake_connection()
     mock_progress = MagicMock()
     mock_progress.moveon = MagicMock()
     self.view.get_script_progress = Mock(return_value=mock_progress)
     self.view.contact_exists = Mock(return_value=False)
     self.view.get_current_step = Mock(return_value=ScriptStep(
         message="Welcome", script=Script(
             slug='ureport_autoreg2'), order=1))
     self.view.get_backend = Mock(return_value=Backend(name="my_backend"))
     response = self.get_http_response_from_view(
         {
             "backend": "my_backend",
             "user_address": "77777"
         }, self.view)
     self.assertEqual(True, mock_progress.moveon.called)
Beispiel #5
0
 def test_that_retrieves_poll_data_from_step_of_script_progress(self):
     fake_connection = Mock()
     fake_connection.return_value = self.build_connection(None)
     self.view.get_connection = fake_connection
     self.view.get_script_progress = Mock(return_value=ScriptProgress(
         script=Script(slug="ureport_autoreg2")))
     fake_get_next_step = Mock(return_value=ScriptStep(
         poll=Poll(name="test poll", question="Is it working?")))
     self.view.get_current_step = fake_get_next_step
     self.view.get_backend = Mock(return_value=Backend(name="my_backend"))
     response = self.get_http_response_from_view(
         {
             "backend": "my_backend",
             "user_address": "77777"
         }, self.view)
     data = json.loads(response.content)
     self.assertEqual(True, data['poll']['is_registration'])
 def get_mocked_step_with_message(self, message):
     mocked_step = ScriptStep()
     mocked_step.message = message
     return mocked_step
Beispiel #7
0
 def get_mocked_step_with_message(self, message):
     mocked_step = ScriptStep()
     mocked_step.message = message
     return mocked_step