Esempio n. 1
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)
Esempio n. 2
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())