def test_should_format_success_message_for_submission_with_blank_if_no_reporter(
         self):
     expected_message = success_messages[SUBMISSION] % "" + "name: tester"
     submission_response = SubmissionResponse(
         success=True,
         submission_id=123,
         errors={},
         processed_data={'name': 'tester'})
     response = Response(reporters=[],
                         submission_response=submission_response)
     message = get_success_msg_for_submission_using(response)
     self.assertEqual(expected_message, message)
Example #2
0
 def test_should_return_expected_success_response(self):
     response = Response(reporters=[{
         NAME_FIELD: "Mr. X"
     }],
                         submission_response=SubmissionResponse(
                             True,
                             "1",
                             datarecord_id="2",
                             short_code="CLI001",
                             processed_data={'name': 'Clinic X'}))
     self.assertEqual(u"Thank you Mr. X. We received : name: Clinic X",
                      SMSResponse(response).text())
 def test_should_format_success_message_for_registration_with_short_code(
         self):
     expected_message = success_messages[
         REGISTRATION] % "Unique identification number(ID) is: REP1"
     submission_response = SubmissionResponse(
         success=True,
         submission_id=123,
         errors={},
         processed_data={'name': 'tester'},
         short_code="REP1")
     response = Response(reporters=[],
                         submission_response=submission_response)
     message = get_success_msg_for_registration_using(response, "web")
     self.assertEqual(expected_message, message)
Example #4
0
 def test_should_return_expected_success_response_for_registration(self):
     response = Response(reporters=[{
         NAME_FIELD: "Mr. X"
     }],
                         submission_response=SubmissionResponse(
                             True,
                             "1",
                             datarecord_id="2",
                             short_code="CLI001",
                             processed_data={'name': 'Clinic X'},
                             is_registration=True))
     self.assertEqual(
         u'Registration successful. Unique identification number(ID) is: CLI001.We received : name: Clinic X',
         SMSResponse(response).text())
 def test_should_format_success_message_for_submission_with_reporter_name(
         self):
     expected_message = success_messages[
         SUBMISSION] % "rep1" + "age: 12 name: tester choice: red"
     submission_response = SubmissionResponse(success=True,
                                              submission_id=123,
                                              errors={},
                                              processed_data={
                                                  'name': 'tester',
                                                  'age': 12,
                                                  'choice': ['red']
                                              })
     response = Response(reporters=[{
         "name": "rep1"
     }],
                         submission_response=submission_response)
     message = get_success_msg_for_submission_using(response)
     self.assertEqual(expected_message, message)
Example #6
0
 def expected_side_effect(*args, **kwargs):
     request = kwargs.get('request') or args[0]
     if request.form_code == 'clf2':
         raise FormModelDoesNotExistsException('')
     return SubmissionResponse(success=True, submission_id=1)