def test_should_update_submission_log_when_subject_info_is_edited(self):
        self.driver.go_to(url("/entity/subject/create/clinic/?web_view=True&"))
        add_subject_page = AddSubjectPage(self.driver)
        add_subject_page.add_subject_with(VALID_DATA_FOR_SUBJECT)
        add_subject_page.submit_subject()
        message = fetch_(SUCCESS_MESSAGE, from_(VALID_DATA_FOR_SUBJECT))

        flash_message = add_subject_page.get_flash_message()
        subject_short_code = get_subject_short_code(flash_message)
        message = message % subject_short_code
        self.assertIn(message, flash_message)

        VALID_SMS_FOR_EDIT_SUBJECT[SMS] = VALID_SMS_FOR_EDIT_SUBJECT[
            SMS].replace('short_code', subject_short_code, 1)
        send_valid_sms_with(VALID_SMS_FOR_EDIT_SUBJECT)

        submission_log_page = self.get_first_project_submission_log_page()
        submission_log_page.search(subject_short_code)
        self.assertIn(fetch_(SUB_LAST_NAME, VALID_DATA_FOR_SUBJECT),
                      submission_log_page.get_cell_value(1, 5))

        self.driver.go_to(url("/entity/subjects/clinic/"))
        subject_list_page = AllSubjectsListPage(self.driver)
        self.driver.wait_for_page_load()
        subject_list_page.select_subject_by_id(subject_short_code)
        edit_subject_page = subject_list_page.click_edit_action_button()
        edit_subject_page.add_subject_with(VALID_DATA_FOR_EDIT)
        edit_subject_page.submit_subject()

        submission_log_page = self.get_first_project_submission_log_page()
        submission_log_page.search(subject_short_code)
        self.assertIn(fetch_(SUB_LAST_NAME, VALID_DATA_FOR_EDIT),
                      submission_log_page.get_cell_value(1, 5))
Exemplo n.º 2
0
    def add_edit_delete_subject(self):
        add_subject_page = AddSubjectPage(self.driver)
        add_subject_page.add_subject_with(VALID_DATA_FOR_SUBJECT_REG)
        add_subject_page.submit_subject()
        flash_message = add_subject_page.get_flash_message()
        subject_short_code = get_subject_short_code(flash_message)
        message = fetch_(
            SUCCESS_MESSAGE,
            from_(VALID_DATA_FOR_SUBJECT_REG)) % subject_short_code
        self.assertIn(message, flash_message)

        add_subject_page.navigate_to_subject_list()
        all_subjects_list_page = AllSubjectsListPage(self.driver)
        all_subjects_list_page.select_subject_by_id(subject_short_code)
        edit_subject_page = all_subjects_list_page.click_edit_action_button()
        edit_subject_page.add_subject_with(VALID_DATA_FOR_EDIT)
        edit_subject_page.submit_subject()
        self.assertEquals(edit_subject_page.get_flash_message(),
                          VALID_DATA_FOR_EDIT[SUCCESS_MESSAGE])

        edit_subject_page.navigate_to_subject_list()
        all_subjects_page = AllSubjectsListPage(self.driver)
        all_subjects_page.select_subject_by_id(subject_short_code)
        all_subjects_page.click_delete_action_button()
        self.driver.find(CONFIRM_DELETE).click()
        self.assertEquals(all_subjects_page.get_successfully_deleted_message(),
                          'Subject(s) successfully deleted.')
        self.assertFalse(
            all_subjects_page.is_subject_present(subject_short_code))
Exemplo n.º 3
0
 def prepare_subject(cls):
     cls.driver.go_to(DATA_WINNER_ADD_SUBJECT + cls.subject_type + "?web_view=True")
     add_subject_page = AddSubjectPage(cls.driver)
     add_subject_page.add_subject_with(VALID_DATA)
     add_subject_page.submit_subject()
     flash_message = add_subject_page.get_flash_message()
     cls.subject_id = flash_message[flash_message.find(":") + 1:].strip()
Exemplo n.º 4
0
 def test_addition_of_subject_with_auto_generate_false(self):
     self.driver.go_to(self.add_subjects_url)
     add_subject_page = AddSubjectPage(self.driver)
     add_subject_page.add_subject_with(SUBJECT_DATA_WITHOUT_UNIQUE_ID)
     add_subject_page.submit_subject()
     message = fetch_(SUCCESS_MSG, from_(SUBJECT_DATA_WITHOUT_UNIQUE_ID))
     self.assertRegexpMatches(add_subject_page.get_flash_message(), message)
Exemplo n.º 5
0
 def test_addition_of_subject_with_existing_data(self):
     self.driver.go_to(self.add_subjects_url)
     add_subject_page = AddSubjectPage(self.driver)
     add_subject_page.add_subject_with(EXISTING_SHORT_CODE)
     short_name = fetch_(SUB_UNIQUE_ID, from_(EXISTING_SHORT_CODE))
     self.driver.find_text_box(UNIQUE_ID_TB).enter_text(short_name)
     add_subject_page.submit_subject()
     message = fetch_(ERROR_MSG, from_(EXISTING_SHORT_CODE))
     self.assertEqual(add_subject_page.get_error_message(), message)
Exemplo n.º 6
0
    def test_addition_of_subject_with_invalid_data(self):
        self.driver.go_to(self.add_subjects_url)
        add_subject_page = AddSubjectPage(self.driver)

        add_subject_page.add_subject_with(WITHOUT_LOCATION_NAME)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG, from_(WITHOUT_LOCATION_NAME))
        self.assertRegexpMatches(add_subject_page.get_error_message(), message)
        a = self.driver.switch_to_active_element()
        self.assertEqual(a.get_attribute("id"), "id_q3")

        add_subject_page.add_subject_with(WITHOUT_GPS)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG, from_(WITHOUT_GPS))
        self.assertRegexpMatches(add_subject_page.get_error_message(), message)

        add_subject_page.add_subject_with(INVALID_LATITUDE_GPS)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG, from_(INVALID_LATITUDE_GPS))
        self.assertErrorMessage(add_subject_page, message)

        add_subject_page.add_subject_with(INVALID_LONGITUDE_GPS)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG, from_(INVALID_LONGITUDE_GPS))
        self.assertErrorMessage(add_subject_page, message)

        add_subject_page.add_subject_with(INVALID_GPS_AND_PHONE_NUMBER)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG, from_(INVALID_GPS_AND_PHONE_NUMBER))
        self.assertErrorMessage(add_subject_page, message)

        add_subject_page.add_subject_with(
            WITH_UNICODE_IN_GPS_AND_INVALID_PHONE_NUMBER)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG,
                         from_(WITH_UNICODE_IN_GPS_AND_INVALID_PHONE_NUMBER))
        self.assertErrorMessage(add_subject_page, message)

        add_subject_page.add_subject_with(CLINIC_WITH_INVALID_UID)
        add_subject_page.submit_subject()
        message = fetch_(ERROR_MSG, from_(CLINIC_WITH_INVALID_UID))
        self.assertRegexpMatches(message, add_subject_page.get_error_message())