Exemple #1
0
 def test_sms_player_for_registration_of_new_subject(self):
     organization = Organization.objects.get(org_id=DEFAULT_TEST_ORG_ID)
     message_tracker_before = organization._get_message_tracker(
         datetime.today())
     response = send_sms_with(REGISTER_NEW_SUBJECT)
     self.assertTrue(
         fetch_(SUCCESS_MESSAGE, from_(REGISTER_NEW_SUBJECT)) in response)
     message_tracker_after = organization._get_message_tracker(
         datetime.today())
     self.assertEqual(message_tracker_before.incoming_sms_count + 1,
                      message_tracker_after.incoming_sms_count)
     self.assertEqual(message_tracker_before.sms_registration_count + 1,
                      message_tracker_after.sms_registration_count)
Exemple #2
0
    def test_pm_should_not_have_ds_permission_to_newly_created_questionnaire(
            self):
        dashboard_page = self.global_navigation.navigate_to_dashboard_page()
        questionnaire_creation_options_page = dashboard_page.navigate_to_create_project_page(
        )
        create_questionnaire_page = questionnaire_creation_options_page.select_blank_questionnaire_creation_option(
        )
        create_questionnaire_page = create_questionnaire_page.create_questionnaire_with(
            CLINIC_PROJECT_DATA, QUESTIONNAIRE_DATA_CLINIC_PROJECT)
        overview_page = create_questionnaire_page.save_and_create_project_successfully(
        )
        my_ds_page = overview_page.navigate_to_datasenders_page()
        questionnaire_code = overview_page.get_questionnaire_code()
        SMS_TO_TEST_PERMISSION[SMS] = CLINIC_SUCCESS_SMS % questionnaire_code
        response = send_sms_with(SMS_TO_TEST_PERMISSION)
        self.assertEqual(response, SUCCESS_MESSAGE_MSG)

        my_ds_page.open_setting_popup()
        my_ds_page.set_setting_value('restricted')
        my_ds_page.save_setting()

        response = send_sms_with(SMS_TO_TEST_PERMISSION)
        self.assertEqual(response, ERROR_MESSAGE_MSG)
Exemple #3
0
    def test_should_check_with_right_order(self):
        test_data = MULTIPLE_WRONG_DATA.copy()
        self.assertEqual(
            send_sms_with(test_data),
            "Error. You are not registered as a Data Sender. Please contact your supervisor."
        )

        test_data.update({SENDER: "2619876"})
        msg = send_sms_with(test_data)
        self.assertEqual(
            msg,
            "Error. Questionnaire Code wrcode is incorrect. Find the Code on the top of the printed Questionnaire and resend SMS starting with this Code."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("wrcode", "cli002")})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. You are not authorized to submit data for this Questionnaire. Please contact your supervisor."
        )

        test_data.update({SENDER: "1234567890"})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. Incorrect number of responses. Please review printed Questionnaire and resend entire SMS.Updated"
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("extradata", "")})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. cid00x5 is not registered. Check the Identification Number and resend entire SMS or contact your supervisor."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("CID00X5", "CID005")})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. Incorrect answer for question 3. Please review printed Questionnaire and resend entire SMS."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("age", "56")})
        self.assertEqual(send_sms_with(test_data),
                         "Thank you Shweta. We received your SMS.")
Exemple #4
0
 def test_sms_player_for_addition_of_data_sender_from_unknown_number(self):
     self.assertEqual(
         send_sms_with(REGISTER_DATA_SENDER_FROM_UNKNOWN_NUMBER),
         fetch_(ERROR_MSG, from_(REGISTER_DATA_SENDER_FROM_UNKNOWN_NUMBER)))
Exemple #5
0
 def test_sms_player_for_exceeding_word_length(self):
     self.assertEqual(send_sms_with(EXCEED_NAME_LENGTH),
                      fetch_(ERROR_MSG, from_(EXCEED_NAME_LENGTH)))
Exemple #6
0
    def test_should_check_with_right_order(self):
        test_data = MULTIPLE_WRONG_DATA.copy()
        test_data['from'] = "4938429843743"
        paid_test_org = Organization.objects.get(org_id=DEFAULT_TEST_ORG_ID)
        print test_data
        self.assertEqual(
            send_sms_with(test_data),
            "Error. You are not registered as a Data Sender. Please contact your supervisor."
        )

        test_data.update({SENDER: "2619876"})
        msg = send_sms_with(test_data)
        self.assertEqual(
            msg,
            "Error. Questionnaire Code wrcode is incorrect. Find the Code on the top of the printed Questionnaire and resend SMS starting with this Code."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("wrcode", "cli002")})
        test_data.update({SENDER: "1234567892"})
        count_before_submission = (self._get_test_paid_org_message_tracker(
            paid_test_org)).incoming_sms_count
        self.assertEqual(
            send_sms_with(test_data),
            "Error. You are not authorized to submit data for this Questionnaire. Please contact your supervisor."
        )
        self.assertEqual(
            count_before_submission + 1,
            self._get_test_paid_org_message_tracker(
                paid_test_org).incoming_sms_count)

        test_data.update({SENDER: "1234567890"})
        count_before_submission = (self._get_test_paid_org_message_tracker(
            paid_test_org)).incoming_sms_count
        self.assertEqual(
            send_sms_with(test_data),
            "Error. Incorrect number of responses. Please review printed Questionnaire and resend entire SMS."
        )
        self.assertEqual(
            count_before_submission + 1,
            self._get_test_paid_org_message_tracker(
                paid_test_org).incoming_sms_count)

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("extradata", "")})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. cid00x5 is not registered. Check the Identification Number and resend entire SMS or contact your supervisor."
        )

        code = self._register_subject_clinic()

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("CID00X5", code)})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. Incorrect answer for question 3. Please review printed Questionnaire and resend entire SMS."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("age", "56")})
        count_before_submission = (self._get_test_paid_org_message_tracker(
            paid_test_org)).incoming_sms_count
        self.assertEqual(send_sms_with(test_data),
                         "Thank you Shweta. We received your SMS.")
        self.assertEqual(
            count_before_submission + 1,
            self._get_test_paid_org_message_tracker(
                paid_test_org).incoming_sms_count)

        self._delete_unique_id(code, 'clinic')
        all_deleted_subjects = json.loads(
            requests.get(url('/api/entity/actions/'),
                         auth=self.DIGEST_CREDENTIALS).content)
        deleted_subjects = [
            dict for dict in all_deleted_subjects
            if dict['entity_type'] == 'clinic'
            and dict['action'] == 'soft-delete' and dict['short_code'] == code
        ]
        self.assertGreaterEqual(len(deleted_subjects), 1)
Exemple #7
0
 def _register_subject_clinic(self):
     response = send_sms_with(REGISTER_NEW_SUBJECT_TO_SOFT_DELETE)
     code = response.split(" ")[-1].rstrip(".")
     return code
Exemple #8
0
 def test_should_not_allow_not_linked_datasender_to_submit_data(self):
     self.assertEqual(send_sms_with(UNAUTHORIZED_DATASENDER),
                      fetch_(ERROR_MSG, from_(UNAUTHORIZED_DATASENDER)))
Exemple #9
0
 def test_sms_player_for_unregistered_subject_and_invalid_geo_code(self):
     self.assertEqual(
         send_sms_with(UNREGISTER_ENTITY_ID_AND_SOME_INVALID_DATA),
         fetch_(ERROR_MSG,
                from_(UNREGISTER_ENTITY_ID_AND_SOME_INVALID_DATA)))
Exemple #10
0
 def test_sms_player_for_registration_with_incorrect_number_of_answers(
         self):
     self.assertEqual(
         fetch_(ERROR_MSG, from_(REGISTER_WITH_WRONG_NUMBER_OF_ANSWERS)),
         send_sms_with(REGISTER_WITH_WRONG_NUMBER_OF_ANSWERS))
Exemple #11
0
 def test_sms_player_for_registration_with_invalid_geo_code(self):
     self.assertEqual(send_sms_with(REGISTER_INVALID_GEO_CODE),
                      fetch_(ERROR_MSG, from_(REGISTER_INVALID_GEO_CODE)))
Exemple #12
0
 def test_sms_player_for_registration_of_existing_subject_short_code(self):
     self.assertEqual(
         send_sms_with(REGISTER_EXISTING_SUBJECT_SHORT_CODE),
         fetch_(ERROR_MSG, from_(REGISTER_EXISTING_SUBJECT_SHORT_CODE)))
Exemple #13
0
 def test_sms_player_for_only_questionnaire_code(self):
     self.assertEqual(send_sms_with(ONLY_QUESTIONNAIRE_CODE),
                      fetch_(ERROR_MSG, from_(ONLY_QUESTIONNAIRE_CODE)))
Exemple #14
0
 def test_sms_player_for_plus_in_the_beginning(self):
     self.assertEqual(send_sms_with(PLUS_IN_THE_BEGINNING),
                      fetch_(ERROR_MSG, from_(PLUS_IN_THE_BEGINNING)))