def test_should_delete_submission(self): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_valid_sms_with(VALID_DATA_FOR_DELETE) message = sms_tester_page.get_response_message() self.assertTrue( fetch_(SUCCESS_MESSAGE, VALID_DATA_FOR_DELETE) in message, "message:" + message) submission_log_page = self.go_to_submission_log_page() submission_log_page.search(unique_text) submission_log_page.wait_for_table_data_to_load() submission_log_page.check_submission_by_row_number(1) submission_log_page.choose_on_dropdown_action(DELETE_BUTTON) warning_dialog = WarningDialog(self.driver) warning_dialog.confirm() time.sleep(1) delete_success_text = self.driver.find_visible_element( by_css('#message_text')).text self.assertEqual(delete_success_text, "The selected records have been deleted") submission_log_page.wait_for_table_data_to_load() self.assertEquals( int(submission_log_page.get_total_number_of_records()), 0)
def test_delete_data_sender_and_re_register(self): all_data_sender_page = self.page self.delete_ds(all_data_sender_page) self.assertEqual(all_data_sender_page.get_delete_success_message(), DELETE_SUCCESS_TEXT) global_navigation = GlobalNavigationPage(self.driver) global_navigation.sign_out() sms_tester_page = SMSTesterPage(self.driver) self.send_sms(VALID_SMS, sms_tester_page) self.assertEqual(sms_tester_page.get_response_message(), SMS_ERROR_MESSAGE) self.login() self.driver.go_to(DATA_WINNER_CREATE_DATA_SENDERS) add_data_sender_page = AddDataSenderPage(self.driver) add_data_sender_page.enter_data_sender_details_from(VALID_DATA) message = add_data_sender_page.get_success_message() self.assertRegexpMatches(message, fetch_(SUCCESS_MSG, from_(VALID_DATA))) self.assertNotEqual(message.split()[-1], fetch_(UID, from_(DELETE_DATA_SENDER))) self.driver.wait_until_modal_dismissed(10) global_navigation.sign_out() self.send_sms(VALID_SMS, sms_tester_page) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SMS))) self.login()
def verify_sms_submission_after_edit(self, new_questionnaire_code): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) VALID_SMS[SMS] = new_questionnaire_code + ' cid001 12.12.2012 mino 25 05.12.2010 a d -18.1324,27.6547 45' sms_tester_page.send_sms_with(VALID_SMS) message = sms_tester_page.get_response_message() self.assertTrue(fetch_(SUCCESS_MESSAGE, VALID_SMS) in message, "message:" + message)
def test_sms_player_for_registration_of_existing_subject_short_code(self): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_EXISTING_SUBJECT_SHORT_CODE) self.assertEqual( sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_EXISTING_SUBJECT_SHORT_CODE)))
def test_should_update_submission_log_when_DS_info_is_edited(self): self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_datasenders_page = AllDataSendersPage(self.driver) ds_id = self.register_datasender(DATASENDER_DETAILS, all_datasenders_page) self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_valid_sms_with(VALID_DATA) message = sms_tester_page.get_response_message() self.assertTrue( fetch_(SUCCESS_MESSAGE, VALID_DATA) in message, "message:" + message) submission_log_page = self.go_to_submission_log_page() submission_log_page.search(ds_id) self.assertTrue(DATASENDER_DETAILS[NAME] in submission_log_page.get_cell_value(row=1, column=2)) self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_datasenders_page.search_with(ds_id) all_datasenders_page.wait_for_table_to_load() all_datasenders_page.select_a_data_sender_by_id(ds_id) all_datasenders_page.select_edit_action() AddDataSenderPage(self.driver).enter_data_sender_details_from( EDITED_DATASENDER_DETAILS) submission_log_page = self.go_to_submission_log_page() submission_log_page.search(ds_id) self.assertTrue(EDITED_DATASENDER_DETAILS[NAME] in submission_log_page.get_cell_value(row=1, column=2))
def test_sms_player_for_addition_of_data_sender_from_unknown_number(self): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_DATA_SENDER_FROM_UNKNOWN_NUMBER) self.assertEqual( sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_DATA_SENDER_FROM_UNKNOWN_NUMBER)))
def send_sms(self, organization_sms_tel_number, sms): sms_tester_page = SMSTesterPage(self.driver) sms_tester_data = sms sms_tester_data[RECEIVER] = str(organization_sms_tel_number) sms_tester_page.send_sms_with(sms_tester_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data))) return sms_tester_page
def test_sms_player_for_plus_in_the_beginning(self): """ Function to test the error message on the sms submission page for plus sign in the beginning of SMS """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(PLUS_IN_THE_BEGINNING) self.assertEqual(sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(PLUS_IN_THE_BEGINNING)))
def test_sms_player_for_unregistered_from_number(self): """ Function to test the error message on the sms submission page for unregistered number in from field """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(UNREGISTERED_FROM_NUMBER) self.assertEqual(sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(UNREGISTERED_FROM_NUMBER)))
def test_sms_player_for_registration_of_reporter(self): """ Function to test the registration of the reporter using sms submission with registered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_REPORTER) self.assertRegexpMatches(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(REGISTER_REPORTER)))
def test_sms_player_for_registration_of_reporter_from_unknown_number(self): """ Function to test the registration of the reporter using sms submission with unregistered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_REPORTER_FROM_UNKNOWN_NUMBER) self.assertEqual(sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_REPORTER_FROM_UNKNOWN_NUMBER)))
def test_sms_player_for_registration_of_new_subject(self): """ Function to test the registration of the new subject using sms submission with registered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_NEW_SUBJECT) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(REGISTER_NEW_SUBJECT)))
def test_sms_player_for_registration_of_existing_subject_short_code(self): """ Function to test the registration of the existing subject short code using sms submission with registered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_EXISTING_SUBJECT_SHORT_CODE) self.assertEqual(sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_EXISTING_SUBJECT_SHORT_CODE)))
def test_sms_player_for_registration_with_invalid_geo_code(self): """ Function to test the registration of the new subject with invalid geo code using sms submission with registered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_INVALID_GEO_CODE) self.assertEqual(sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_INVALID_GEO_CODE)))
def test_successful_sms_submission(self): """ Function to test the successful SMS submission """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(VALID_DATA) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_DATA)))
def test_sms_player_without_entering_data(self): """ Function to test the error message on the sms submission page for blank field """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(BLANK_FIELDS) self.assertEqual(sms_tester_page.get_error_message(), fetch_(ERROR_MSG, from_(BLANK_FIELDS)))
def test_sms_player_for_exceeding_word_length(self): """ Function to test the error message on the sms submission page for exceeding word limit for word type question """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(EXCEED_NAME_LENGTH) self.assertEqual(sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(EXCEED_NAME_LENGTH)))
def _submit_errorred_data(self, questionnaire_code): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) page = SMSTesterPage(self.driver) sms_data = get_errorred_sms_data_with_questionnaire_code( questionnaire_code) page.send_sms_with(sms_data) self.assertTrue( fetch_(MESSAGE, from_(sms_data)) in page.get_response_message())
def _submit_sms_data(cls, questionnaire_code, monthly): cls.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) page = SMSTesterPage(cls.driver) dates = get_reporting_date_values(monthly) for i in dates: page.send_sms_with( get_sms_data_with_questionnaire_code(questionnaire_code, i)) assert 'Thank you' in page.get_response_message()
def test_sms_player_for_registration_of_reporter_from_unknown_number(self): """ Function to test the registration of the reporter using sms submission with unregistered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_REPORTER_FROM_UNKNOWN_NUMBER) self.assertEqual( sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_REPORTER_FROM_UNKNOWN_NUMBER)))
def test_sms_player_for_registration_of_existing_subject_short_code(self): """ Function to test the registration of the existing subject short code using sms submission with registered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_EXISTING_SUBJECT_SHORT_CODE) self.assertEqual( sms_tester_page.get_response_message(), fetch_(ERROR_MSG, from_(REGISTER_EXISTING_SUBJECT_SHORT_CODE)))
def test_sms_player_for_registration_of_reporter(self): """ Function to test the registration of the reporter using sms submission with registered number """ self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(REGISTER_REPORTER) self.assertRegexpMatches( sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(REGISTER_REPORTER)))
def do_sms_submission(self, questionnaire_code, sms_data, project_title): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_data[SMS] = sms_data[SMS] % questionnaire_code sms_tester_page.send_sms_with(sms_data) message = sms_tester_page.get_response_message() self.assertTrue( fetch_(SUCCESS_MESSAGE, sms_data) in message, "message:" + message) self.driver.go_to(DATA_WINNER_ALL_PROJECTS_PAGE) ProjectsPage(self.driver).navigate_to_project_overview_page(project_title)\ .navigate_to_questionnaire_tab()
def _submit_errorred_data(self, questionnaire_code): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) page = SMSTesterPage(self.driver) sms_data = get_errorred_sms_data_with_questionnaire_code( questionnaire_code) page.send_sms_with(sms_data) result = fetch_(MESSAGE, from_(sms_data)) in page.get_response_message() if not result: self.driver.create_screenshot("debug-ft-msg-not-in-response") self.assertTrue(result)
def send_submission(self, questionnaire_code): self.driver.execute_script("window.open('%s')" % DATA_WINNER_SMS_TESTER_PAGE) new_tab = self.driver.window_handles[1] first_tab = self.driver.window_handles[0] self.driver.switch_to_window(new_tab) sms_tester_page = SMSTesterPage(self.driver) valid_sms = { SENDER: "2619875", RECEIVER: '919880734937', SMS: "%s 10.10.2010" % questionnaire_code } sms_tester_page.send_sms_with(valid_sms) response = sms_tester_page.get_response_message() self.assertRegexpMatches(response, THANKS) self.driver.close() self.driver.switch_to_window(first_tab)
def prerequisites_of_submission_log(self, sms_data): self.driver.go_to(DATA_WINNER_LOGIN_PAGE) login_page = LoginPage(self.driver) dashboard_page = login_page.do_successful_login_with(VALID_CREDENTIALS) self.assertEqual(dashboard_page.welcome_message(), fetch_(WELCOME_MESSAGE, from_(VALID_CREDENTIALS))) self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(sms_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(MESSAGE, from_(sms_data))) self.driver.go_to(DATA_WINNER_DASHBOARD_PAGE) time.sleep(5) view_all_project_page = dashboard_page.navigate_to_view_all_project_page() time.sleep(3) project_overview_project = view_all_project_page.navigate_to_project_page(PROJECT_NAME) time.sleep(3) data_page = project_overview_project.navigate_to_data_page() time.sleep(3) submission_log_page = data_page.navigate_to_all_data_record_page() return submission_log_page
def test_should_update_submission_log_when_subject_info_is_edited(self): self.dashboard.navigate_to_all_subject_page() all_subject_type_page = AllSubjectTypePage(self.driver) add_subject_page = all_subject_type_page.select_subject_type( 'Clinic').navigate_to_register_subject_page() 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() self.assertIn(message, flash_message) subject_short_code = flash_message.replace(message, '') self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) VALID_SMS_FOR_EDIT_SUBJECT[SMS] = VALID_SMS_FOR_EDIT_SUBJECT[ SMS].replace('short_code', subject_short_code, 1) sms_tester_page.send_valid_sms_with(VALID_SMS_FOR_EDIT_SUBJECT) submission_log_page = self.go_to_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.dashboard.navigate_to_all_subject_page() all_subject_type_page = AllSubjectTypePage(self.driver) add_subject_page = all_subject_type_page.select_subject_type( 'Clinic').navigate_to_register_subject_page() add_subject_page.navigate_to_subject_list() subject_list_page = AllSubjectsListPage(self.driver) 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.go_to_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))
def test_should_filter_by_name_and_id_of_datasender_and_subject(self): self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_valid_sms_with(SMS_REGISTER_SUBJECT) sms_tester_page.send_valid_sms_with(SMS_WEB_SUBMISSION) submission_log_page = self.go_to_submission_log_page() datasender_name = 'Tester' submission_log_page.filter_by_datasender(datasender_name) submission_log_page.wait_for_table_data_to_load() self._verify_filtered_records_by_datasender_name_or_id( datasender_name, submission_log_page) project_name = fetch_("last_name", from_(SUBJECT_DATA)) submission_log_page.filter_by_subject(project_name) submission_log_page.wait_for_table_data_to_load() self._verify_filtered_records_by_subject_name_or_id( project_name, submission_log_page) datasender_id = 'rep276' submission_log_page.filter_by_datasender(datasender_id) submission_log_page.wait_for_table_data_to_load() self._verify_filtered_records_by_datasender_name_or_id( datasender_id, submission_log_page) project_short_code = fetch_("short_code", from_(SUBJECT_DATA)) submission_log_page.filter_by_subject(project_short_code) submission_log_page.wait_for_table_data_to_load() self._verify_filtered_records_by_subject_name_or_id( project_short_code, submission_log_page)
def test_should_show_warning_when_deleting_question_in_questionnaire_having_data(self): self.driver.go_to(DATA_WINNER_LOGIN_PAGE) all_subject_page = self.global_navigation.navigate_to_all_subject_page() all_subject_page.add_new_subject_type(SUBJECT_TYPE) time.sleep(2) edit_registration_form = all_subject_page.navigate_to_edit_registration_form(SUBJECT_TYPE, True) first_tab = self.driver.current_window_handle edit_registration_form.delete_question(5) self.driver.execute_script("window.open('%s')" % DATA_WINNER_SMS_TESTER_PAGE) new_tab = self.driver.window_handles[1] self.driver.switch_to_window(new_tab) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(VALID_SMS_SUBJECT_DATA) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, VALID_SMS_SUBJECT_DATA)) self.assertEqual(first_tab, self.driver.window_handles[0]) self.driver.close() self.driver.switch_to_window(first_tab) warning_dialog = WarningDialog(self.driver) edit_registration_form.save_questionnaire() self.assertEqual(SAVE_QUESTIONNAIRE_WITH_NEWLY_COLLECTED_DATA_WARNING, warning_dialog.get_message()) warning_dialog.cancel() edit_registration_form.delete_question(4) self.assertEqual(DELETE_QUESTIONNAIRE_WITH_COLLECTED_DATA_WARNING, warning_dialog.get_message())
def prerequisites_of_submission_log(self, sms_data): self.driver.go_to(DATA_WINNER_LOGIN_PAGE) login_page = LoginPage(self.driver) dashboard_page = login_page.do_successful_login_with(VALID_CREDENTIALS) self.assertEqual(dashboard_page.welcome_message(), fetch_(WELCOME_MESSAGE, from_(VALID_CREDENTIALS))) self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(sms_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(MESSAGE, from_(sms_data))) self.driver.go_to(DATA_WINNER_DASHBOARD_PAGE) time.sleep(5) view_all_project_page = dashboard_page.navigate_to_view_all_project_page( ) time.sleep(3) project_overview_project = view_all_project_page.navigate_to_project_page( PROJECT_NAME) time.sleep(3) data_page = project_overview_project.navigate_to_data_page() time.sleep(3) submission_log_page = data_page.navigate_to_all_data_record_page() return submission_log_page
def test_successful_questionnaire_editing(self): """ Function to test the successful editing of a Questionnaire with given details """ create_questionnaire_page = self.prerequisites_of_edit_questionnaire() questions = fetch_(QUESTIONS, from_(QUESTIONNAIRE_DATA)) create_questionnaire_page.select_question_link(2) self.assertEqual(questions[0], create_questionnaire_page.get_word_type_question()) create_questionnaire_page.select_question_link(3) self.assertEqual(questions[1], create_questionnaire_page.get_number_type_question()) create_questionnaire_page.select_question_link(4) self.assertEqual(questions[2], create_questionnaire_page.get_date_type_question()) create_questionnaire_page.select_question_link(5) self.assertEqual(questions[3], create_questionnaire_page.get_list_of_choices_type_question()) create_questionnaire_page.select_question_link(6) self.assertEqual(questions[4], create_questionnaire_page.get_list_of_choices_type_question()) first_tab = self.driver.current_window_handle create_questionnaire_page.delete_question(7) time.sleep(2) self.driver.execute_script("window.open('%s')" % DATA_WINNER_SMS_TESTER_PAGE) new_tab = self.driver.window_handles[1] self.driver.switch_to_window(new_tab) sms_tester_page = SMSTesterPage(self.driver) sms_tester_page.send_sms_with(VALID_SMS) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, VALID_SMS)) self.assertEqual(first_tab, self.driver.window_handles[0]) self.driver.switch_to_window(first_tab) create_questionnaire_page.save_and_create_project() time.sleep(2) warning_dialog = WarningDialog(self.driver) self.assertEqual(SAVE_QUESTIONNAIRE_WITH_NEWLY_COLLECTED_DATA_WARNING, warning_dialog.get_message()) warning_dialog.cancel() create_questionnaire_page.delete_question(5) time.sleep(2) self.assertEqual(DELETE_QUESTIONNAIRE_WITH_COLLECTED_DATA_WARNING, warning_dialog.get_message()) warning_dialog.cancel()
def test_intregation_of_application(self): self.driver.go_to(DATA_WINNER_LOGIN_PAGE) login_page = LoginPage(self.driver) registration_page = login_page.navigate_to_registration_page() self.assertEqual(registration_page.get_title(), "Register") registration_confirmation_page, self.email = registration_page.successful_registration_with( REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION) self.assertEquals( registration_confirmation_page.registration_success_message(), fetch_(SUCCESS_MESSAGE, from_(REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION))) dbmanager = DatabaseManager() organization_sms_tel_number = get_epoch_last_ten_digit() dbmanager.set_sms_telephone_number(organization_sms_tel_number, self.email) account_activate_page = ActivateAccountPage(self.driver) dbmanager = DatabaseManager() activation_code = dbmanager.get_activation_code(self.email) account_activate_page.activate_account(activation_code) self.assertRegexpMatches( account_activate_page.get_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS))) self.driver.go_to(DATA_WINNER_LOGIN_PAGE) VALID_LOGIN_CREDENTIALS = VALID_CREDENTIALS VALID_LOGIN_CREDENTIALS[USERNAME] = self.email dashboard_page = login_page.do_successful_login_with( VALID_LOGIN_CREDENTIALS) self.assertEqual( dashboard_page.welcome_message(), fetch_(WELCOME_MESSAGE, from_(VALID_LOGIN_CREDENTIALS))) register_reporter_page = dashboard_page.navigate_to_register_reporter_page( ) register_reporter_page.register_with(VALID_DATA_FOR_REPORTER) self.assertRegexpMatches( register_reporter_page.get_success_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_DATA_FOR_REPORTER))) self.driver.go_to(DATA_WINNER_ADD_SUBJECT) add_subject_type_page = AddSubjectTypePage(self.driver) add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE1) self.assertEqual(add_subject_type_page.get_flash_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE1))) add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE2) self.assertEqual(add_subject_type_page.get_flash_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE2))) self.driver.go_to(DATA_WINNER_HOME_PAGE) register_subject_page = dashboard_page.navigate_to_register_subject_page( ) message = register_subject_page.successfully_register_subject_with( VALID_DATA_FOR_SUBJECT) self.assertRegexpMatches(register_subject_page.get_flash_message(), message) self.driver.go_to(DATA_WINNER_HOME_PAGE) create_project_page = dashboard_page.navigate_to_create_project_page() create_subject_questionnaire_page = create_project_page.successfully_create_project_with( VALID_DATA_FOR_PROJECT) self.assertRegexpMatches( create_subject_questionnaire_page.get_title(), fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_PROJECT))) create_questionnaire_page = create_subject_questionnaire_page.successfully_create_subject_questionnaire_with( None) self.assertRegexpMatches( create_questionnaire_page.get_title(), fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_SUBJECT_QUESTIONNAIRE))) create_questionnaire_page.create_questionnaire_with(QUESTIONNAIRE_DATA) index = 2 for question in fetch_(QUESTIONS, from_(QUESTIONNAIRE_DATA)): question_link_text = fetch_(QUESTION, from_(question)) + " " + fetch_( CODE, from_(question)) self.assertEquals( create_questionnaire_page.get_question_link_text(index), question_link_text) index += 1 time.sleep(5) self.assertEquals( create_questionnaire_page.get_remaining_character_count(), fetch_(CHARACTER_REMAINING, from_(QUESTIONNAIRE_DATA))) create_questionnaire_page.save_questionnaire() time.sleep(3) self.assertEqual(create_questionnaire_page.get_title(), "Finish & Test") self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_data = VALID_DATA_FOR_SMS sms_tester_data[RECEIVER] = organization_sms_tel_number sms_tester_page.send_sms_with(sms_tester_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data))) self.driver.go_to(DATA_WINNER_HOME_PAGE) view_all_project_page = dashboard_page.navigate_to_view_all_project_page( ) time.sleep(3) project_overview_project = view_all_project_page.navigate_to_project_page( fetch_(PROJECT_NAME, VALID_DATA_FOR_PROJECT)) time.sleep(3) data_page = project_overview_project.navigate_to_data_page() time.sleep(3) submission_log_page = data_page.navigate_to_all_data_record_page() time.sleep(3) self.assertRegexpMatches( submission_log_page.get_submission_message(SMS_DATA_LOG), fetch_(SMS_SUBMISSION, from_(SMS_DATA_LOG))) self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_data = VALID_DATA_FOR_SMS sms_tester_data[RECEIVER] = organization_sms_tel_number sms_tester_page.send_sms_with(sms_tester_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data)))
def test_intregation_of_application(self): self.driver.go_to(DATA_WINNER_LOGIN_PAGE) login_page = LoginPage(self.driver) registration_page = login_page.navigate_to_registration_page() self.assertEqual(registration_page.get_title(), "Register") registration_confirmation_page, self.email = registration_page.successful_registration_with(REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION) self.assertEquals(registration_confirmation_page.registration_success_message(), fetch_(SUCCESS_MESSAGE, from_(REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION))) dbmanager = DatabaseManager() organization_sms_tel_number = get_epoch_last_ten_digit() dbmanager.set_sms_telephone_number(organization_sms_tel_number, self.email) account_activate_page = ActivateAccountPage(self.driver) dbmanager = DatabaseManager() activation_code = dbmanager.get_activation_code(self.email) account_activate_page.activate_account(activation_code) self.assertRegexpMatches(account_activate_page.get_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS))) self.driver.go_to(DATA_WINNER_LOGIN_PAGE) VALID_LOGIN_CREDENTIALS = VALID_CREDENTIALS VALID_LOGIN_CREDENTIALS[USERNAME] = self.email dashboard_page = login_page.do_successful_login_with(VALID_LOGIN_CREDENTIALS) self.assertEqual(dashboard_page.welcome_message(), fetch_(WELCOME_MESSAGE, from_(VALID_LOGIN_CREDENTIALS))) register_reporter_page = dashboard_page.navigate_to_register_reporter_page() register_reporter_page.register_with(VALID_DATA_FOR_REPORTER) self.assertRegexpMatches(register_reporter_page.get_success_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_DATA_FOR_REPORTER))) self.driver.go_to(DATA_WINNER_ADD_SUBJECT) add_subject_type_page = AddSubjectTypePage(self.driver) add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE1) self.assertEqual(add_subject_type_page.get_flash_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE1))) add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE2) self.assertEqual(add_subject_type_page.get_flash_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE2))) self.driver.go_to(DATA_WINNER_HOME_PAGE) register_subject_page = dashboard_page.navigate_to_register_subject_page() message = register_subject_page.successfully_register_subject_with(VALID_DATA_FOR_SUBJECT) self.assertRegexpMatches(register_subject_page.get_flash_message(), message) self.driver.go_to(DATA_WINNER_HOME_PAGE) create_project_page = dashboard_page.navigate_to_create_project_page() create_subject_questionnaire_page = create_project_page.successfully_create_project_with(VALID_DATA_FOR_PROJECT) self.assertRegexpMatches(create_subject_questionnaire_page.get_title(), fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_PROJECT))) create_questionnaire_page = create_subject_questionnaire_page.successfully_create_subject_questionnaire_with(None) self.assertRegexpMatches(create_questionnaire_page.get_title(), fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_SUBJECT_QUESTIONNAIRE))) create_questionnaire_page.create_questionnaire_with(QUESTIONNAIRE_DATA) index = 2 for question in fetch_(QUESTIONS, from_(QUESTIONNAIRE_DATA)): question_link_text = fetch_(QUESTION, from_(question)) + " " + fetch_(CODE, from_(question)) self.assertEquals(create_questionnaire_page.get_question_link_text(index), question_link_text) index += 1 time.sleep(5) self.assertEquals(create_questionnaire_page.get_remaining_character_count(), fetch_(CHARACTER_REMAINING, from_(QUESTIONNAIRE_DATA))) create_questionnaire_page.save_questionnaire() time.sleep(3) self.assertEqual(create_questionnaire_page.get_title(), "Finish & Test") self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_tester_data = VALID_DATA_FOR_SMS sms_tester_data[RECEIVER] = organization_sms_tel_number sms_tester_page.send_sms_with(sms_tester_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data))) self.driver.go_to(DATA_WINNER_HOME_PAGE) view_all_project_page = dashboard_page.navigate_to_view_all_project_page() time.sleep(3) project_overview_project = view_all_project_page.navigate_to_project_page(fetch_(PROJECT_NAME, VALID_DATA_FOR_PROJECT)) time.sleep(3) data_page = project_overview_project.navigate_to_data_page() time.sleep(3) submission_log_page = data_page.navigate_to_all_data_record_page() time.sleep(3) self.assertRegexpMatches(submission_log_page.get_submission_message(SMS_DATA_LOG), fetch_(SMS_SUBMISSION, from_(SMS_DATA_LOG))) self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_data = VALID_DATA_FOR_SMS sms_tester_data[RECEIVER] = organization_sms_tel_number sms_tester_page.send_sms_with(sms_tester_data) self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data)))
def test_project_reply_sms_language(self): languages_page = self.automatic_reply_sms_page.choose_automatic_reply_language('new') new_language = 'kannada' + random_string(4) languages_page.add_new_language(new_language) self.assertEqual(languages_page.get_success_message(), 'Your language has been added successfully. Please translate the suggested automatic reply SMS text.') languages_page.wait_till_success_message_box_disappears() languages_page.append_custom_message_for(SUCCESS_SUBMISSION_MESSAGE_LOCATOR, 'Dhanyawaadagalu') languages_page.append_custom_message_for(SUBMISSION_WITH_ERROR_MESSAGE_LOCATOR, 'Tappu uttara') languages_page.append_custom_message_for(SUBMISSION_WITH_INCORRECT_NUMBER_OF_RESPONSES_LOCATOR, 'Tappada sankhyeya uttaragalu') languages_page.append_custom_message_for(SUBMISSION_WITH_INCORRECT_UNIQUE_ID, 'daakhaleyalli illa') languages_page.append_custom_message_for(RESPONSE_ERROR_MESSAGE_FROM_UNAUTHORIZED_SOURCE_LOCATOR, 'Nimage anumathi illa') languages_page.save_changes() self.assertEqual(languages_page.get_success_message(), 'Changes saved successfully.') self.change_project_language(new_language, self.project_name) self.driver.go_to(FAILED_SUBMISSIONS_PAGE) failed_submission_entry_count = FailedSubmissionsPage(self.driver).get_total_number_of_entries() self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) sms_data = get_success_sms_data_with_questionnaire_code(self.questionnaire_code) sms_tester_page.send_sms_with(sms_data) message = sms_tester_page.get_response_message() self.assertIn('Dhanyawaadagalu', message) sms_data = get_error_sms_data_with_questionnaire_code(self.questionnaire_code) sms_tester_page.send_sms_with(sms_data) self.assertIn('Tappu uttara', sms_tester_page.get_response_message()) sms_with_incorrect_number_of_answers = get_error_sms_data_with_incorrect_number_of_answers(self.questionnaire_code) sms_tester_page.send_sms_with(sms_with_incorrect_number_of_answers) self.assertIn('Tappada sankhyeya uttaragalu', sms_tester_page.get_response_message()) sms_data = get_error_sms_data_with_incorrect_unique_id(self.questionnaire_code) sms_tester_page.send_sms_with(sms_data) self.assertIn('daakhaleyalli illa', sms_tester_page.get_response_message()) self.driver.go_to(FAILED_SUBMISSIONS_PAGE) failed_submissions_page = FailedSubmissionsPage(self.driver) current_failed_submission_entry_count = failed_submissions_page.get_total_number_of_entries() self.assertEqual(current_failed_submission_entry_count, failed_submission_entry_count+1) self.assertEqual(sms_with_incorrect_number_of_answers[SMS], failed_submissions_page.get_entry_for_row_number(1)['message'])
def test_should_use_modified_account_wide_sms_messages_to_send_reply(self): new_custom_messages = [ u'Error. You are not registered as a Data Sender. Please contact your supervisor.new message', u'Error. Questionnaire Code {<{Submitted Questionnaire Code}>} is incorrect. Find the Code on the top of the printed Questionnaire and resend SMS starting with this Code.new message', u'Thank you {<{Name of Data Sender}>}.We registered your {<{Identification Number Type}>} {<{Name of Identification Number}>} {<{Submitted Identification Number}>}.new message', u'Error. Incorrect answer for question {<{Question Numbers for Wrong Answer(s)}>}. Please review printed Questionnaire and resend entire SMS.new message', u'Error. Incorrect number of responses. Please review printed Questionnaire and resend entire SMS.new message', u'Error. {<{Submitted Identification Number}>} already exists. Register your {<{Identification Number Type}>} with a different Identification Number.new message' ] self.change_account_messages() self.account_sms_page.save_changes() self.driver.go_to(FAILED_SUBMISSIONS_PAGE) total_failed_submission_count = FailedSubmissionsPage( self.driver).get_total_number_of_entries() self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE) sms_tester_page = SMSTesterPage(self.driver) incorrect_ds_number_data = { "from": "4444444", "to": '919880734937', "sms": "qcode sender_name 45 cid001" } sms_tester_page.send_sms_with(incorrect_ds_number_data) message = sms_tester_page.get_response_message() self.assertEquals(new_custom_messages[0], message) incorrect_qcode_data = { "from": "1234123413", "to": '919880734937', "sms": "wrcode sender_name 45 cid001" } sms_tester_page.send_sms_with(incorrect_qcode_data) message = sms_tester_page.get_response_message() self.assertEquals( 'Error. Questionnaire Code wrcode is incorrect. Find the Code on the top of the printed Questionnaire and resend SMS starting with this Code.new message', message) success_subject_registration_data = { "from": "1234123413", "to": '919880734937', "sms": "peo fname lname location 4,4 898989898" } sms_tester_page.send_sms_with(success_subject_registration_data) success_message = sms_tester_page.get_response_message() registered_short_code = re.match('.*(peo\d+).*', success_message).groups()[0] self.assertEquals( 'Thank you Tester.We registered your people lname ' + registered_short_code + '.new message', success_message) error_subject_registration = { "from": "1234123413", "to": '919880734937', "sms": "peo fname lname location 4,4 898989898 " + registered_short_code } sms_tester_page.send_sms_with(error_subject_registration) message = sms_tester_page.get_response_message() self.assertIn('new message', message) self.driver.go_to(FAILED_SUBMISSIONS_PAGE) failed_submissions_page = FailedSubmissionsPage(self.driver) current_failed_submission_count = failed_submissions_page.get_total_number_of_entries( ) self.assertEqual(current_failed_submission_count, total_failed_submission_count + 2) self.assertEqual( incorrect_ds_number_data[SMS], failed_submissions_page.get_entry_for_row_number(2)['message']) self.assertEqual( incorrect_qcode_data[SMS], failed_submissions_page.get_entry_for_row_number(1)['message']) self.reset_account_messages()