Example #1
0
  def assertAdminCanBeRemoved(self, test_url):
    """Test that removing an admin works from the given url.

    Args:
      test_url: The url to remove the admin from.
    """
    # Login as an existing admin to get access.
    LoginPage(self.driver).Login(self.args.server_url, self.args.email,
                                 self.args.password)
    self.driver.get(test_url)

    # Find the add admin dialog.
    admin_flow = AdminFlow(self.driver)
    dropdown_menu = admin_flow.getDropdownMenu()
    add_admin_dialog = admin_flow.get_add_admin_dialog(dropdown_menu)

    # Add the test admin.
    admin_flow.add_test_admin(self.TEST_ADMIN_AS_DICT['email'],
                              self.TEST_ADMIN_AS_DICT['password'],
                              add_admin_dialog)

    # Remove the test admin.
    admin_flow.close_dropdown_menu_from_dialog(add_admin_dialog)
    admin_flow.remove_test_admin(self.TEST_ADMIN_AS_DICT['email'],
                                 self.args.server_url,
                                 should_raise_exception=True,
                                 should_navigate_to_landing=False)

    # See if the admin exists.
    self.driver.get(test_url)
    dropdown_menu = admin_flow.getDropdownMenu()
    remove_admin_dialog = admin_flow.get_remove_admin_dialog(dropdown_menu)
    remove_admin_form = remove_admin_dialog.find_element(
        *AdminFlow.REMOVE_ADMIN_FORM)
    admin_item = admin_flow.find_test_admin_on_remove_form(
        self.TEST_ADMIN_AS_DICT['email'], remove_admin_form)

    self.assertIsNone(admin_item)