Ejemplo n.º 1
0
    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))
Ejemplo 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))
Ejemplo n.º 3
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()
     flash_message = add_subject_page.get_flash_message()
     message = fetch_(SUCCESS_MSG, from_(SUBJECT_DATA_WITHOUT_UNIQUE_ID))
     message = message % get_subject_short_code(flash_message)
     self.assertRegexpMatches(flash_message, message)
Ejemplo n.º 4
0
 def test_register_subject(self):
     add_subject_page = self.data_sender_page.register_subject()
     self.assertEquals(add_subject_page.get_title(), PAGE_TITLE)
     self.assertEquals(add_subject_page.get_section_title(), SECTION_TITLE)
     self.assertEquals(add_subject_page.get_subject_type(), SUBJECT_TYPE)
     add_subject_page.add_subject_with(VALID_DATA)
     add_subject_page.submit_subject()
     message = fetch_(SUCCESS_MSG, from_(VALID_DATA))
     flash_message = add_subject_page.get_flash_message()
     message = message % get_subject_short_code(flash_message)
     self.assertIn(message, flash_message)
Ejemplo n.º 5
0
 def register_new_subject_of_type(self, subject_type, subject_data):
     global_navigation = GlobalNavigationPage(self.driver)
     global_navigation.navigate_to_all_subject_page()
     all_subject_type_page = AllSubjectTypePage(self.driver)
     add_subject_page = all_subject_type_page.select_subject_type(
         subject_type).navigate_to_register_subject_page()
     add_subject_page.add_subject_with(subject_data)
     add_subject_page.submit_subject()
     flash_message = add_subject_page.get_flash_message()
     message = fetch_(
         SUCCESS_MESSAGE,
         from_(subject_data)) % get_subject_short_code(flash_message)
     self.assertIn(message, flash_message)
Ejemplo n.º 6
0
 def add_subject(self, subject_type, subject_data):
     global_navigation = GlobalNavigationPage(self.driver)
     global_navigation.navigate_to_all_subject_page()
     add_subject_page = AddSubjectTypePage(self.driver).add_subject_type(
         subject_type, username=self.email, password=REGISTRATION_PASSWORD)
     add_subject_page = AddSubjectPage(self.driver)
     add_subject_page.refresh()
     AllSubjectTypePage(self.driver).select_subject_type(
         subject_type).navigate_to_register_subject_page()
     add_subject_page.add_subject_with(subject_data)
     add_subject_page.submit_subject()
     flash_message = add_subject_page.get_flash_message()
     message = fetch_(
         SUCCESS_MESSAGE,
         from_(subject_data)) % get_subject_short_code(flash_message)
     self.assertIn(message, flash_message)