예제 #1
0
    def test_should_change_a_project_manager_to_extended_user(self):
        self.global_navigation = login(self.driver, VALID_CREDENTIALS)
        self.driver.go_to(ALL_USERS_URL)
        all_users_page = AllUsersPage(self.driver)
        add_user_page = all_users_page.navigate_to_add_user()
        user = generate_user()
        add_user_page.select_role_as_project_manager()
        add_user_page.select_questionnaires(2, 4)
        add_user_page.add_user_with(user)
        message = add_user_page.get_success_message()
        self.assertEqual(message, ADDED_USER_SUCCESS_MSG)
        self.driver.go_to(ALL_USERS_URL)
        self.all_users_page = AllUsersPage(self.driver)
        username = fetch_(USERNAME, user)
        self.assertTrue(
            self.all_users_page.is_editable(username),
            '%s user was expected to be editable but was not editable')
        self.all_users_page.select_user_with_username(username)
        edit_user_page = self.all_users_page.select_edit_action()

        self.assertTrue(edit_user_page.is_user_name_is_prefetched(username))
        self.assertTrue(edit_user_page.is_role_project_manager())
        edit_user_page.select_role_as_administrator()
        edit_user_page.save_changes()
        edit_user_page.get_success_message()
        self.driver.go_to(ALL_USERS_URL)
        self.assertEqual('Administrator',
                         self.all_users_page.get_role_for(username))
        self.assertEqual(
            'All',
            self.all_users_page.get_questionnaire_list_for(username)[0])
        self.global_navigation.sign_out()
예제 #2
0
 def test_should_change_a_extended_user_to_project_manager(self):
     user = generate_user()
     self._create_extended_user(user)
     username = fetch_(USERNAME, user)
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     self.assertTrue(
         self.all_users_page.is_editable(username),
         '%s user was expected to be editable but was not editable')
     self.all_users_page.select_user_with_username(username)
     edit_user_page = self.all_users_page.select_edit_action()
     self.assertTrue(edit_user_page.is_user_name_is_prefetched(username))
     self.assertTrue(edit_user_page.is_role_administrator())
     edit_user_page.select_role_as_project_manager()
     selected_questionnaires = edit_user_page.select_questionnaires(3)
     edit_user_page.save_changes()
     edit_user_page.get_success_message()
     self.driver.go_to(ALL_USERS_URL)
     questionnaire_list_for_user = self.all_users_page.get_questionnaire_list_for(
         username)
     self.assertEqual(set(questionnaire_list_for_user),
                      set(selected_questionnaires))
     self.assertEqual('Project Manager',
                      self.all_users_page.get_role_for(username))
     self.global_navigation.sign_out()
예제 #3
0
 def _create_extended_user(self, user):
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     self.add_user_page = self.all_users_page.navigate_to_add_user()
     self.add_user_page.select_role_as_administrator()
     self.add_user_page.add_user_with(user)
     self.add_user_page.get_success_message()
 def delete_user(self):
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     all_users_page.check_nth_user(2)
     all_users_page.select_delete_action(confirm=True)
     message = all_users_page.get_message()
     self.assertEqual(message, SUCCESSFULLY_DELETED_USER_MSG)
예제 #5
0
 def _create_project_manager(self, user):
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     self.add_user_page = self.all_users_page.navigate_to_add_user()
     self.add_user_page.select_role_as_project_manager()
     self.add_user_page.select_questionnaires(1, 0)
     self.add_user_page.add_user_with(user)
     self.add_user_page.get_success_message()
예제 #6
0
 def add_new_user(cls, user_data):
     cls.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(cls.driver)
     add_user_page = all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(user_data)
     cls.driver.wait_for_element(UI_TEST_TIMEOUT,
                                 by_css("div.success-message-box"), True)
     user_mobile_number = fetch_(MOBILE_PHONE, user_data)
     return user_mobile_number
예제 #7
0
 def add_new_user(cls, user_data):
     cls.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(cls.driver)
     add_user_page = all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(user_data)
     cls.driver.wait_for_element(UI_TEST_TIMEOUT * 2, FLASH_MESSAGE_LABEL,
                                 True)
     user_mobile_number = fetch_(MOBILE_PHONE, user_data)
     return user_mobile_number
예제 #8
0
    def test_should_check_validations_while_editing_an_user(self):
        # Create a Project Manager
        user = generate_user()
        self._create_extended_user(user)
        self.driver.go_to(ALL_USERS_URL)
        self.all_users_page = AllUsersPage(self.driver)
        existing_mobile_number = self.all_users_page.get_mobile_number_for(
            user.get(USERNAME))
        add_user_page = self.all_users_page.navigate_to_add_user()
        user = generate_user()
        add_user_page.select_role_as_project_manager()
        add_user_page.select_questionnaires(2, 4)
        add_user_page.add_user_with(user)
        add_user_page.get_success_message()
        username = user[USERNAME]

        # Edit the Project Manager
        self.driver.go_to(ALL_USERS_URL)
        self.all_users_page.select_user_with_username(username)
        edit_user_page = self.all_users_page.select_edit_action()

        updated_user_data = {NAME: ""}
        edit_user_page.edit_values(updated_user_data)

        message = edit_user_page.get_error_messages()
        self.assertEqual(message, u'This field is required')

        updated_user_data = {NAME: "Test User", MOBILE_PHONE: ""}
        edit_user_page.edit_values(updated_user_data)

        message = edit_user_page.get_error_messages()
        self.assertEqual(message, u'This field is required')

        updated_user_data = {MOBILE_PHONE: "Some text value"}
        edit_user_page.edit_values(updated_user_data)

        message = edit_user_page.get_error_messages()
        self.assertEqual(message, u'Invalid phone number')

        updated_user_data = {MOBILE_PHONE: "1234"}
        edit_user_page.edit_values(updated_user_data)

        message = edit_user_page.get_error_messages()
        self.assertEqual(message, u'Invalid phone number')

        updated_user_data = {MOBILE_PHONE: existing_mobile_number}
        edit_user_page.save_changes(updated_user_data)

        message = edit_user_page.get_error_messages()
        self.assertEqual(
            message,
            u'This phone number is already in use. Please supply a different phone number'
        )
        self.global_navigation.sign_out()
        edit_user_page.confirm_leave_page()
예제 #9
0
 def delete_user(self, username):
     self.global_navigation.sign_out()
     login(self.driver, VALID_CREDENTIALS)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     self.driver.find(by_xpath("//td[contains(.,'%s')]/../td/input" % username)).click()
     all_users_page.select_delete_action(confirm=True)
     self.driver.wait_for_element(UI_TEST_TIMEOUT, by_css("span.loading"), True)
     self.driver.wait_until_modal_dismissed()
     message = all_users_page.get_message()
     self.assertEqual(message, SUCCESSFULLY_DELETED_USER_MSG)
예제 #10
0
    def test_should_show_warning_when_trying_to_leave_page_without_saving(
            self):
        self.driver.go_to(ALL_USERS_URL)
        all_users_page = AllUsersPage(self.driver)
        all_users_page.select_user_with_username("*****@*****.**")
        edit_user_page = all_users_page.select_edit_action()
        edit_user_page.select_role_as_administrator()
        self.edit_user_page.switch_language("en")

        expected_msg = """You have made changes to the form. These changes will be lost if you navigate away from this page.\n\nAre you sure you want to proceed?"""
        alert_msg = self.edit_user_page.get_warning_dialog_message()
        self.assertEqual(alert_msg, expected_msg)
예제 #11
0
    def test_should_show_warning_when_trying_to_leave_page_without_saving(
            self):
        self.global_navigation = login(self.driver, VALID_CREDENTIALS)
        self.driver.go_to(ALL_USERS_URL)
        all_users_page = AllUsersPage(self.driver)
        all_users_page.select_user_with_username("*****@*****.**")
        edit_user_page = all_users_page.select_edit_action()
        edit_user_page.select_role_as_administrator()
        self.driver.refresh()
        expected_msg = u'This page is asking you to confirm that you want to leave - data you have entered may not be saved.'

        alert = self.driver.switch_to_alert()
        self.assertEqual(alert.text, expected_msg)
예제 #12
0
 def test_should_add_a_new_user(self):
     self.global_navigation = login(self.driver, VALID_CREDENTIALS)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     add_user_page = all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(ADD_USER_DATA)
     message = add_user_page.get_success_message()
     self.assertEqual(message, ADDED_USER_SUCCESS_MSG)
     username = fetch_(USERNAME, ADD_USER_DATA)
     password = DEFAULT_PASSWORD
     new_user_credential = {USERNAME: username, PASSWORD: password}
     self.global_navigation.sign_out()
     login(self.driver, new_user_credential)
     title = self.driver.get_title()
     self.assertEqual(title, DASHBOARD_PAGE_TITLE)
예제 #13
0
    def test_should_make_sure_that_ds_permission_is_removed_in_the_same_time_as_user_permission_is_removed(
            self):
        self.driver.go_to(ALL_USERS_URL)
        all_users_page = AllUsersPage(self.driver)
        all_users_page.select_user_with_username("*****@*****.**")
        edit_user_page = all_users_page.select_edit_action()
        edit_user_page._uncheck_all_questionnaires()
        edit_user_page.save_changes()
        edit_user_page.get_success_message()
        response = send_sms_with(SMS_TO_TEST_PERMISSION)
        self.assertEqual(response, ERROR_MESSAGE)
        edit_user_page.select_questionnaires_by_name(["clinic test project1"])
        edit_user_page.save_changes()

        edit_user_page.get_success_message()
        response = send_sms_with(SMS_TO_TEST_PERMISSION)
        self.assertEqual(response, SUCCESS_MESSAGE)
예제 #14
0
 def test_should_update_user_name_when_edited_from_datasender_page(self):
     add_user_page = self.all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(EDIT_USER_DATA)
     self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE)
     all_datasenders_page = AllDataSendersPage(self.driver)
     all_datasenders_page.search_with(EDIT_USER_DATA.get('username'))
     self.driver.find(all_datasenders_page.get_checkbox_selector_for_datasender_row(1)).click()
     all_datasenders_page.select_edit_action()
     EDIT_DETAILS = {"name": "New testUser",
                     "mobile_number": EDIT_USER_DATA.get("mobile_phone"),
                     "commune": "Madagascar",
                     "gps": "-21.7622088847 48.0690991394"}
     AddDataSenderPage(self.driver).enter_data_sender_details_from(EDIT_DETAILS).navigate_to_datasender_page()
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     element = self.driver.find(by_xpath(NAME_COLUMN % EDIT_USER_DATA.get("username")))
     self.assertEquals(EDIT_DETAILS.get("name"),element.text)
예제 #15
0
 def test_should_add_a_new_project_manager_as_extended_user(self):
     self.add_user_page.select_role_as_administrator()
     user = generate_user()
     self.add_user_page.add_user_with(user)
     message = self.add_user_page.get_success_message()
     self.assertEqual(message, ADDED_USER_SUCCESS_MSG)
     self.username = fetch_(USERNAME, user)
     password = DEFAULT_PASSWORD
     self.new_user_credential = {USERNAME: self.username, PASSWORD: password}
     self.global_navigation.sign_out()
     login(self.driver, self.new_user_credential)
     title = self.driver.get_title()
     self.assertEqual(title, DASHBOARD_PAGE_TITLE)
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     self.add_user_page = self.all_users_page.navigate_to_add_user()
     self.assertFalse(self.add_user_page.is_administrator_role_visible(),
                      'Expected Administrator Role not to be present but it was present')
     questionnaires = self.add_user_page.select_questionnaires(2)
     user = generate_user()
     self.add_user_page.add_user_with(user)
     message = self.add_user_page.get_success_message()
     self.assertEqual(message, ADDED_USER_SUCCESS_MSG)
     self.username = fetch_(USERNAME, user)
     password = DEFAULT_PASSWORD
     self.new_user_credential = {USERNAME: self.username, PASSWORD: password}
     self.driver.go_to(ALL_USERS_URL)
     questionnaire_list_for_user = self.all_users_page.get_questionnaire_list_for(self.username)
     role_for_user = self.all_users_page.get_role_for(self.username)
     self.assertEqual('Project Manager', role_for_user,
                      'Expected role to be Project Manager but was %s' % role_for_user)
     if not questionnaires[0] in questionnaire_list_for_user:
         self.driver.create_screenshot("debug-ft-qre-not-in-list")
         raise Exception("%s not in [%s] for user %s" % (questionnaires[0], ", ".join(questionnaire_list_for_user), self.username))
     self.assertTrue(questionnaires[0] in questionnaire_list_for_user)
     self.assertTrue(questionnaires[1] in questionnaire_list_for_user)
     self.assertEqual(2, len(questionnaire_list_for_user),
                      'Expected the questionnaires length to be 2 but was %s' %
                      len(questionnaire_list_for_user))
     self.global_navigation.sign_out()
     login(self.driver, self.new_user_credential)
     title = self.driver.get_title()
     self.assertEqual(title, DASHBOARD_PAGE_TITLE)
 def test_should_create_activity_log_and_submit_data(self):
     all_users_page = self.prerequisites_for_all_users()
     add_user_page = all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(NEW_USER_DATA)
     self.driver.go_to(LOGOUT)
     new_user_credential = {
         USERNAME: NEW_USER_DATA[USERNAME],
         PASSWORD: "******"
     }
     self.login(credential=new_user_credential)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     add_user_page = all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(ADD_USER_DATA)
     self.driver.go_to(url("/project/"))
     project_name, questionnaire_code = self.create_project()
     self.send_submission(questionnaire_code)
     self.delete_user(NEW_USER_DATA[USERNAME])
     self.check_sent_submission(project_name)
     self.check_deleted_user_name_on_activity_log_page(project_name)
예제 #17
0
    def test_should_edit_a_project_manager_as_ngo_admin(self):
        self.global_navigation = login(self.driver, VALID_CREDENTIALS)
        self.driver.go_to(ALL_USERS_URL)
        all_users_page = AllUsersPage(self.driver)
        add_user_page = all_users_page.navigate_to_add_user()
        user = generate_user()
        add_user_page.select_role_as_project_manager()
        add_user_page.select_questionnaires(2, 4)
        add_user_page.add_user_with(user)
        add_user_page.get_success_message()
        username = fetch_(USERNAME, user)
        self.driver.go_to(ALL_USERS_URL)
        questionnaire_list_for_user = all_users_page.get_questionnaire_list_for(
            username)
        all_users_page.select_user_with_username(username)
        edit_user_page = all_users_page.select_edit_action()
        self.assertTrue(edit_user_page.is_user_name_is_prefetched(username))
        self.assertTrue(edit_user_page.is_role_project_manager())
        self.assertTrue(
            edit_user_page.are_questionnaires_preselected(
                questionnaire_list_for_user))
        selected_questionnaires = edit_user_page.select_questionnaires(3)
        edit_user_page.save_changes({
            "mobile_phone": random_number(9),
            "full_name": 'New User Name'
        })
        success_message = edit_user_page.get_success_message()
        self.assertEqual(
            USER_EDITED_SUCCESS_MESSAGE, success_message,
            'Expected "User has been updated successfully" message but was not found'
        )

        self.driver.go_to(ALL_USERS_URL)
        self.assertEqual('New User Name',
                         all_users_page.get_full_name_for(username))
        self.assertEqual(
            3, len(selected_questionnaires),
            'Expected the questionnaires length to be 3 but was %s' %
            len(selected_questionnaires))
        self.global_navigation.sign_out()
예제 #18
0
 def test_should_edit_an_extended_user_as_ngo_admin(self):
     self.global_navigation = login(self.driver, VALID_CREDENTIALS)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     add_user_page = all_users_page.navigate_to_add_user()
     user = generate_user()
     add_user_page.select_role_as_administrator()
     add_user_page.add_user_with(user)
     message = add_user_page.get_success_message()
     username = fetch_(USERNAME, user)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page.select_user_with_username(username)
     edit_user_page = all_users_page.select_edit_action()
     self.assertTrue(edit_user_page.is_user_name_is_prefetched(username))
     self.assertTrue(edit_user_page.is_role_administrator())
     edit_user_page.save_changes({"mobile_phone": random_number(9)})
     success_message = edit_user_page.get_success_message()
     self.assertEqual(
         USER_EDITED_SUCCESS_MESSAGE, success_message,
         'Expected "User has been updated successfully" message but was not found'
     )
     self.global_navigation.sign_out()
예제 #19
0
 def create_user_and_open_it_on_edit_page(self,
                                          isAdmin=True,
                                          questionnaires=[]):
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     add_user_page = self.all_users_page.navigate_to_add_user()
     user = generate_user()
     if isAdmin:
         add_user_page.select_role_as_administrator()
     else:
         add_user_page.select_role_as_project_manager()
         add_user_page.select_questionnaires(*questionnaires)
     add_user_page.add_user_with(user)
     message = add_user_page.get_success_message()
     self.username = fetch_(USERNAME, user)
     self.driver.go_to(ALL_USERS_URL)
     self.user_questionnaire_list = self.all_users_page.get_questionnaire_list_for(
         self.username)
     self.assertTrue(
         self.all_users_page.is_editable(self.username),
         '%s user was expected to be editable but was not editable')
     self.all_users_page.select_user_with_username(self.username)
     self.edit_user_page = self.all_users_page.select_edit_action()
예제 #20
0
    def test_should_edit_a_project_manager_as_extended_user(self):
        user = {
            TITLE: "Developer",
            NAME: random_string(7),
            USERNAME: random_string(7) + "@mailinator.com",
            MOBILE_PHONE: random_number(9)
        }
        new_user = {
            TITLE: "Developer",
            NAME: random_string(7),
            USERNAME: random_string(7) + "@mailinator.com",
            MOBILE_PHONE: random_number(9)
        }

        # create extended user
        self._create_extended_user(user)
        username = fetch_(USERNAME, user)
        password = DEFAULT_PASSWORD
        extended_user_credentials = {USERNAME: username, PASSWORD: password}
        self.global_navigation.sign_out()

        # Login with extended user and create project manager
        login(self.driver, extended_user_credentials)
        self.driver.wait_for_page_with_title(UI_TEST_TIMEOUT, "Dashboard")
        self.assertEqual("Dashboard", self.driver.get_title())
        self.driver.go_to(ALL_USERS_URL)

        self.all_users_page = AllUsersPage(self.driver)
        self.assertEqual(
            0,
            self.all_users_page.number_of_editable_users_for_role(
                'Administrator'),
            'Expected Administrators to be non-editable but was editable')
        self.assertEqual(
            0,
            self.all_users_page.number_of_editable_users_for_role(
                'Super Admin'),
            'Expected Super Admin to be non-editable but was editable')
        self.add_user_page = self.all_users_page.navigate_to_add_user()
        self.add_user_page.select_questionnaires(2)
        self.add_user_page.add_user_with(new_user)
        self.add_user_page.get_success_message()
        username = fetch_(USERNAME, new_user)
        self.driver.go_to(ALL_USERS_URL)
        self.assertGreater(
            1,
            self.all_users_page.number_of_editable_users_for_role(
                'Super Admin'),
            'Expected Super Admin to be non-editable but was editable')
        self.assertTrue(
            self.all_users_page.is_editable(username),
            '%s user was expected to be editable but was not editable')
        questionnaire_list_for_user = self.all_users_page.get_questionnaire_list_for(
            username)
        time.sleep(10)
        self.all_users_page.select_user_with_username(username)
        edit_user_page = self.all_users_page.select_edit_action()
        self.assertTrue(edit_user_page.is_user_name_is_prefetched(username))
        self.assertTrue(edit_user_page.is_role_project_manager())
        qre_pre_selected = edit_user_page.are_questionnaires_preselected(
            questionnaire_list_for_user, True)
        self.assertTrue(qre_pre_selected)
        selected_questionnaires = edit_user_page.select_questionnaires(3)
        edit_user_page.save_changes({
            "mobile_phone": random_number(9),
            "full_name": 'New User Name'
        })
        success_message = edit_user_page.get_success_message()
        self.assertEqual(
            USER_EDITED_SUCCESS_MESSAGE, success_message,
            'Expected "User has been updated successfully" message but was not found'
        )

        self.driver.go_to(ALL_USERS_URL)
        self.assertEqual('New User Name',
                         self.all_users_page.get_full_name_for(username))
        self.assertEqual(
            3, len(selected_questionnaires),
            'Expected the questionnaires length to be 3 but was %s' %
            len(selected_questionnaires))
 def prerequisites_for_all_users(self):
     self.login()
     self.driver.go_to(ALL_USERS_URL)
     return AllUsersPage(self.driver)
예제 #22
0
 def select_user_tab(self):
     self.driver.find(USER_TAB).click()
     return AllUsersPage(self.driver)
예제 #23
0
 def setUp(self):
     self.global_navigation = login(self.driver, VALID_CREDENTIALS)
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     self.add_user_page = self.all_users_page.navigate_to_add_user()
예제 #24
0
 def prerequest_for_add_user_page(self):
     self.login()
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     return all_users_page.navigate_to_add_user()