def test_adding_users_by_roles(self, test_case_id, test_user_id, test_univ_id, role, role_id, canvas_role, success_msg_ind, remove_list_ind, error_msg_ind, add_remove_indicator): if add_remove_indicator != 'add': return test_univ_id = self.normalize_xlrd_number(test_univ_id, '{0:08d}') test_user_id = self.normalize_xlrd_number(test_user_id, '{0:08d}') role_id = self.normalize_xlrd_number(role_id) self.start_message(test_user_id, test_univ_id, role, role_id) # Note: ICOMMONS_REST_API_HOST environment needs to match the LTI tool # environment (because of shared cache interactions) # ensure person is not in course before attempting to add using API; # remove ALL roles/enrollments for the test user in this course # to ensure no incidental data causes conflict when we try to add self.api.remove_user( self.test_settings['test_course']['cid'], test_univ_id) user_list_page = UserListPageObject(self.driver) search_page = FindUserPageObject(self.driver) results_page = ResultsListPageObject(self.driver) # from Main/User list page: click links to add people to course user_list_page.add_user() # from Search page: find a user and submit form search_page.find_user(test_user_id) # verify that we are now on the results page from search self.assertTrue(results_page.is_loaded(), "Problem finding user %s: results page not loaded" % test_user_id) results_page.add_id_to_course(test_univ_id, role) self.assertTrue(results_page.user_confirmation_visible(), 'User %s with role %s could not be added to the ' 'course; another conflicting role may exist for ' 'the user already.' % (test_univ_id, role_id)) results_page.return_to_manage_people() self.assertTrue( user_list_page.user_present_with_role(test_univ_id, role_id)) # ensure person is removed from course as cleanup self.api.remove_user( self.test_settings['test_course']['cid'], test_univ_id, role_id)
def test_remove_users(self, test_case_id, test_user_id, test_univ_id, role, role_id, canvas_role, success_msg_ind, remove_list_ind, error_msg_ind, add_remove_ind): if add_remove_ind != 'remove': return test_univ_id = self.normalize_xlrd_number(test_univ_id, '{0:08d}') role_id = self.normalize_xlrd_number(role_id) self.start_message(test_user_id, test_univ_id, role, role_id) # Note: ICOMMONS_REST_API_HOST environment needs to match the LTI tool # environment (because of shared cache interactions) # ensure person is in course before attempting to remove using API # 1. remove ALL roles/enrollments for the test user in this course # to ensure no incidental data causes conflict when we try to add # 2. add via API the role we want to test removing through the UI self.api.remove_user( self.test_settings['test_course']['cid'], test_univ_id) self.api.add_user( self.test_settings['test_course']['cid'], test_univ_id, role_id) user_list_page = UserListPageObject(self.driver) # Note: the refresh has been added due to issues with remove. If # user is added via the api but the page isn't reload, the tests will # sporadically fail out with NoSuchElementException. self.driver.refresh() self.setUp() # Delete the user in Canvas user_list_page.delete_user(test_univ_id, role_id) self.assertTrue(user_list_page.is_loaded()) # Note: the refresh has been added due to issues with remove. If the # user has been deleted via the UI, but the page isn't reloaded, # it would sporadically fail out with an assertion error. We have # yet to find a more graceful solution. self.driver.refresh() self.setUp() # Assert that the deleted user does not appear in Manage People self.assertFalse( user_list_page.user_present_with_role(test_univ_id, role_id))
def test_adding_users_by_roles(self, test_case_id, test_user_id, test_univ_id, role, role_id, canvas_role, success_msg_ind, remove_list_ind, error_msg_ind, add_remove_indicator): if add_remove_indicator != 'add': return test_univ_id = self.normalize_xlrd_number(test_univ_id, '{0:08d}') test_user_id = self.normalize_xlrd_number(test_user_id, '{0:08d}') role_id = self.normalize_xlrd_number(role_id) self.start_message(test_user_id, test_univ_id, role, role_id) # Note: ICOMMONS_REST_API_HOST environment needs to match the LTI tool # environment (because of shared cache interactions) # ensure person is not in course before attempting to add using API; # remove ALL roles/enrollments for the test user in this course # to ensure no incidental data causes conflict when we try to add self.api.remove_user(self.test_settings['test_course']['cid'], test_univ_id) user_list_page = UserListPageObject(self.driver) search_page = FindUserPageObject(self.driver) results_page = ResultsListPageObject(self.driver) # from Main/User list page: click links to add people to course user_list_page.add_user() # from Search page: find a user and submit form search_page.find_user(test_user_id) # verify that we are now on the results page from search self.assertTrue( results_page.is_loaded(), "Problem finding user %s: results page not loaded" % test_user_id) results_page.add_id_to_course(test_univ_id, role) self.assertTrue( results_page.user_confirmation_visible(), 'User %s with role %s could not be added to the ' 'course; another conflicting role may exist for ' 'the user already.' % (test_univ_id, role_id)) results_page.return_to_manage_people() self.assertTrue( user_list_page.user_present_with_role(test_univ_id, role_id)) # ensure person is removed from course as cleanup self.api.remove_user(self.test_settings['test_course']['cid'], test_univ_id, role_id)
def test_search_by_huid_unsuccessful(self): """ This searches for an invalid id and asserts that search page is not loaded and user is not found """ user_list_page = UserListPageObject(self.driver) search_page = FindUserPageObject(self.driver) fake_huid = self.test_settings["test_users"]["fake"]["user_id"] user_list_page.add_user() search_page.find_user(fake_huid) self.assertTrue(search_page.is_loaded()) self.assertTrue(search_page.user_not_found())
def test_search_by_huid_unsuccessful(self): """ This searches for an invalid id and asserts that search page is not loaded and user is not found """ user_list_page = UserListPageObject(self.driver) search_page = FindUserPageObject(self.driver) fake_huid = self.test_settings['test_users']['fake']['user_id'] user_list_page.add_user() search_page.find_user(fake_huid) self.assertTrue(search_page.is_loaded()) self.assertTrue(search_page.user_not_found())
def test_remove_users(self, test_case_id, test_user_id, test_univ_id, role, role_id, canvas_role, success_msg_ind, remove_list_ind, error_msg_ind, add_remove_ind): if add_remove_ind != 'remove': return test_univ_id = self.normalize_xlrd_number(test_univ_id, '{0:08d}') role_id = self.normalize_xlrd_number(role_id) self.start_message(test_user_id, test_univ_id, role, role_id) # Note: ICOMMONS_REST_API_HOST environment needs to match the LTI tool # environment (because of shared cache interactions) # ensure person is in course before attempting to remove using API # 1. remove ALL roles/enrollments for the test user in this course # to ensure no incidental data causes conflict when we try to add # 2. add via API the role we want to test removing through the UI self.api.remove_user( self.test_settings['test_course']['cid'], test_univ_id) self.api.add_user( self.test_settings['test_course']['cid'], test_univ_id, role_id) user_list_page = UserListPageObject(self.driver) # note delete_user() requires the Canvas role name, not our display # name (e.g. ObserverEnrollment, not Observer) # Note: the refresh has been added due to issues with remove. If # user is added via the api but the page isn't reload, the tests will # sporadically fail out with NoSuchElementException. self.driver.refresh() self.setUp() user_list_page.delete_user(test_univ_id, canvas_role) # Verify that user is not on the page after getting removed self.assertTrue(user_list_page.is_loaded()) self.assertFalse( user_list_page.user_present_with_role(test_univ_id, role))
def test_search_by_huid_successful(self): """ This searches for an existing ID and asserts the search results page is loaded after search """ user_list_page = UserListPageObject(self.driver) search_page = FindUserPageObject(self.driver) results_page = ResultsListPageObject(self.driver) test_user = self.test_settings["test_users"]["1"] # ensure person isn't in course before attempting to search self.api.remove_user(self.test_settings["test_course"]["cid"], test_user["user_id"], test_user["role_id"]) user_list_page.add_user() search_page.find_user(test_user["user_id"]) self.assertTrue(results_page.is_loaded())
def test_search_by_huid_successful(self): """ This searches for an existing ID and asserts the search results page is loaded after search """ user_list_page = UserListPageObject(self.driver) search_page = FindUserPageObject(self.driver) results_page = ResultsListPageObject(self.driver) test_user = self.test_settings['test_users']['1'] # ensure person isn't in course before attempting to search self.api.remove_user(self.test_settings['test_course']['cid'], test_user['user_id'], test_user['role_id']) user_list_page.add_user() search_page.find_user(test_user['user_id']) self.assertTrue(results_page.is_loaded())
def setUp(self): """ Redirects browser to test course URL and login to PIN using specified credentials. """ super(CourseAdminBaseTestCase, self).setUp() # instantiate self.dashboard_page = CourseAdminDashboardPage(self.driver) self.manage_people = UserListPageObject(self.driver) self.test_settings = settings.SELENIUM_CONFIG['manage_people'] # initialize if not self.dashboard_page.is_loaded(): self.dashboard_page.get(self.TOOL_URL) # navigate to cross-list tool self.dashboard_page.select_manage_people_link() # check if page is loaded (which will also set the focus on the tool) self.assertTrue(self.manage_people.is_loaded())
def test_remove_users(self, test_case_id, test_user_id, test_univ_id, role, role_id, canvas_role, success_msg_ind, remove_list_ind, error_msg_ind, add_remove_ind): if add_remove_ind != 'remove': return test_univ_id = self.normalize_xlrd_number(test_univ_id, '{0:08d}') role_id = self.normalize_xlrd_number(role_id) self.start_message(test_user_id, test_univ_id, role, role_id) # Note: ICOMMONS_REST_API_HOST environment needs to match the LTI tool # environment (because of shared cache interactions) # ensure person is in course before attempting to remove using API # 1. remove ALL roles/enrollments for the test user in this course # to ensure no incidental data causes conflict when we try to add # 2. add via API the role we want to test removing through the UI self.api.remove_user(self.test_settings['test_course']['cid'], test_univ_id) self.api.add_user(self.test_settings['test_course']['cid'], test_univ_id, role_id) user_list_page = UserListPageObject(self.driver) # Note: the refresh has been added due to issues with remove. If # user is added via the api but the page isn't reload, the tests will # sporadically fail out with NoSuchElementException. self.driver.refresh() self.setUp() # Delete the user in Canvas user_list_page.delete_user(test_univ_id, role_id) self.assertTrue(user_list_page.is_loaded()) # Note: the refresh has been added due to issues with remove. If the # user has been deleted via the UI, but the page isn't reloaded, # it would sporadically fail out with an assertion error. We have # yet to find a more graceful solution. self.driver.refresh() self.setUp() # Assert that the deleted user does not appear in Manage People self.assertFalse( user_list_page.user_present_with_role(test_univ_id, role_id))