"Fossies" - the Fresh Open Source Software Archive

Member "horizon-16.0.0/openstack_dashboard/test/integration_tests/pages/identity/userspage.py" (16 Oct 2019, 2631 Bytes) of package /linux/misc/openstack/horizon-16.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 #    not use this file except in compliance with the License. You may obtain
    3 #    a copy of the License at
    4 #
    5 #         http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 #    Unless required by applicable law or agreed to in writing, software
    8 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 #    License for the specific language governing permissions and limitations
   11 #    under the License.
   12 
   13 from openstack_dashboard.test.integration_tests.pages import basepage
   14 from openstack_dashboard.test.integration_tests.regions import forms
   15 from openstack_dashboard.test.integration_tests.regions import tables
   16 
   17 
   18 class UsersTable(tables.TableRegion):
   19     name = 'users'
   20     CREATE_USER_FORM_FIELDS = ("name", "email", "password",
   21                                "confirm_password", "project", "role_id")
   22 
   23     @tables.bind_table_action('create')
   24     def create_user(self, create_button):
   25         create_button.click()
   26         return forms.FormRegion(self.driver, self.conf,
   27                                 field_mappings=self.CREATE_USER_FORM_FIELDS)
   28 
   29     @tables.bind_table_action('delete')
   30     def delete_user(self, delete_button):
   31         delete_button.click()
   32         return forms.BaseFormRegion(self.driver, self.conf)
   33 
   34 
   35 class UsersPage(basepage.BaseNavigationPage):
   36 
   37     USERS_TABLE_NAME_COLUMN = 'name'
   38 
   39     def __init__(self, driver, conf):
   40         super(UsersPage, self).__init__(driver, conf)
   41         self._page_title = "Users"
   42 
   43     def _get_row_with_user_name(self, name):
   44         return self.users_table.get_row(self.USERS_TABLE_NAME_COLUMN, name)
   45 
   46     @property
   47     def users_table(self):
   48         return UsersTable(self.driver, self.conf)
   49 
   50     def create_user(self, name, password,
   51                     project, role, email=None):
   52         create_user_form = self.users_table.create_user()
   53         create_user_form.name.text = name
   54         if email is not None:
   55             create_user_form.email.text = email
   56         create_user_form.password.text = password
   57         create_user_form.confirm_password.text = password
   58         create_user_form.project.text = project
   59         create_user_form.role_id.text = role
   60         create_user_form.submit()
   61 
   62     def delete_user(self, name):
   63         row = self._get_row_with_user_name(name)
   64         row.mark()
   65         confirm_delete_users_form = self.users_table.delete_user()
   66         confirm_delete_users_form.submit()
   67 
   68     def is_user_present(self, name):
   69         return bool(self._get_row_with_user_name(name))