Example #1
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))
    def navigate_to_add_a_subject_page(self):
        """
        Function to navigate to add a subject page of the website

        Return create project page
         """
        self.driver.find(ADD_A_SUBJECT_LINK).click()
        return AddSubjectPage(self.driver)
Example #3
0
    def click_edit_action_button(self):
        for i in range(0, 3):
            self._select_subject_action()
            if self._wait_for_element_visible():
                break

        self.driver.find_visible_element(by_css(".edit")).click()
        return AddSubjectPage(self.driver)
    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))
Example #5
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()
Example #6
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)
Example #7
0
    def test_cancel_link_should_be_available_for_datasender(self):
        self.driver.go_to(LOGOUT)
        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        login_page = LoginPage(self.driver)
        login_page.login_with(DATA_SENDER_CREDENTIALS)

        self.driver.go_to(self.add_subjects_url)

        self.assertRegexpMatches(
            (AddSubjectPage(self.driver)).get_cancel_url(), "/alldata/")
Example #8
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)
 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)
 def click_register_subject(self):
     self.driver.find(REGISTER_SUBJECT_LINK).click()
     return AddSubjectPage(self.driver)
Example #11
0
 def navigate_to_register_subject_page(self):
     self.driver.find(by_id("register_subjects")).click()
     return AddSubjectPage(self.driver)
Example #12
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())