def test_that_get_script_progress_for_poll_returns_none_if_there_is_no_script_progress_for_the_poll(self):
     poll = self.setup_poll()
     view = SubmitPollResponses()
     backend = Backend.objects.create(name="test_backend")
     view.connection = Connection.objects.create(identity="7777", backend=backend)
     script_progress = view.get_script_progress_for_poll(poll)
     self.assertEqual(None, script_progress)
예제 #2
0
 def test_that_get_script_progress_for_poll_returns_none_if_there_is_no_script_progress_for_the_poll(
         self):
     poll = self.setup_poll()
     view = SubmitPollResponses()
     backend = Backend.objects.create(name="test_backend")
     view.connection = Connection.objects.create(identity="7777",
                                                 backend=backend)
     script_progress = view.get_script_progress_for_poll(poll)
     self.assertEqual(None, script_progress)
 def test_that_get_script_progress_for_poll_returns_script_progress(self):
     poll = self.setup_poll()
     view = SubmitPollResponses()
     backend = Backend.objects.create(name="test_backend")
     view.connection = Connection.objects.create(identity="7777", backend=backend)
     script, created = Script.objects.get_or_create(slug="ureport_autoreg2")
     ScriptStep.objects.create(script=script, order=1, poll=poll)
     script_progress = ScriptProgress.objects.create(connection=view.connection, script=script)
     script_progress.start()
     self.assertEqual(script_progress, view.get_script_progress_for_poll(poll))
 def test_that_that_script_progress_moves_to_next_step_if_exists(self):
     poll = self.setup_poll()
     view = SubmitPollResponses()
     backend = Backend.objects.create(name="test_backend")
     view.connection = Connection.objects.create(identity="7777", backend=backend)
     script, created = Script.objects.get_or_create(slug="ureport_autoreg2")
     ScriptStep.objects.create(script=script, order=1, poll=poll)
     ScriptStep.objects.create(script=script, order=2, message="")
     script_progress = ScriptProgress.objects.create(connection=view.connection, script=script)
     script_progress.start()
     view.process_registration_steps(poll)
     reloaded_script_progress = ScriptProgress.objects.get(pk=script_progress.id)
     self.assertEqual(2, reloaded_script_progress.step.order)
예제 #5
0
 def test_that_get_script_progress_for_poll_returns_script_progress(self):
     poll = self.setup_poll()
     view = SubmitPollResponses()
     backend = Backend.objects.create(name="test_backend")
     view.connection = Connection.objects.create(identity="7777",
                                                 backend=backend)
     script, created = Script.objects.get_or_create(slug="ureport_autoreg2")
     ScriptStep.objects.create(script=script, order=1, poll=poll)
     script_progress = ScriptProgress.objects.create(
         connection=view.connection, script=script)
     script_progress.start()
     self.assertEqual(script_progress,
                      view.get_script_progress_for_poll(poll))
 def test_process_poll_returns_an_outgoing_message(self):
     backend = Backend.objects.create(name="test_backend")
     connection = Connection.objects.create(identity="7777", backend=backend)
     contact, contact_created = Contact.objects.get_or_create(name='John Jonny')
     connection.contact = contact
     connection.save()
     script = Script.objects.create(slug="who")
     ScriptSession.objects.create(connection=connection, script=script)
     default_response = "Thanks"
     poll = self.setup_poll(default_response)
     view = SubmitPollResponses()
     view.connection = connection
     accepted, outgoing_message = view.process_poll_response("Yes", poll)
     self.assertEqual(True, accepted)
     self.assertEqual(default_response, outgoing_message)
예제 #7
0
 def test_that_that_script_progress_moves_to_next_step_if_exists(self):
     poll = self.setup_poll()
     view = SubmitPollResponses()
     backend = Backend.objects.create(name="test_backend")
     view.connection = Connection.objects.create(identity="7777",
                                                 backend=backend)
     script, created = Script.objects.get_or_create(slug="ureport_autoreg2")
     ScriptStep.objects.create(script=script, order=1, poll=poll)
     ScriptStep.objects.create(script=script, order=2, message="")
     script_progress = ScriptProgress.objects.create(
         connection=view.connection, script=script)
     script_progress.start()
     view.process_registration_steps(poll)
     reloaded_script_progress = ScriptProgress.objects.get(
         pk=script_progress.id)
     self.assertEqual(2, reloaded_script_progress.step.order)
예제 #8
0
 def test_process_poll_returns_an_outgoing_message(self):
     backend = Backend.objects.create(name="test_backend")
     connection = Connection.objects.create(identity="7777",
                                            backend=backend)
     contact, contact_created = Contact.objects.get_or_create(
         name='John Jonny')
     connection.contact = contact
     connection.save()
     script = Script.objects.create(slug="who")
     ScriptSession.objects.create(connection=connection, script=script)
     default_response = "Thanks"
     poll = self.setup_poll(default_response)
     view = SubmitPollResponses()
     view.connection = connection
     accepted, outgoing_message = view.process_poll_response("Yes", poll)
     self.assertEqual(True, accepted)
     self.assertEqual(default_response, outgoing_message)