~ubuntu-branches/ubuntu/utopic/horizon/utopic

« back to all changes in this revision

Viewing changes to openstack_dashboard/test/integration_tests/pages/settingspage.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-07-25 11:39:09 UTC
  • mfrom: (1.1.42)
  • Revision ID: package-import@ubuntu.com-20140725113909-b8920pdy87itn1ro
Tags: 1:2014.2~b2-0ubuntu1
* New upstream release.
* debian/patches/ubuntu_settings.patch: Refresed
* debian/patches/fix-dashboard-manage.patch: Refreshed
* debian/patches/fix-dashboard-django-wsgi.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 selenium.webdriver.common import by
 
14
 
 
15
from openstack_dashboard.test.integration_tests.pages import basepage
 
16
from openstack_dashboard.test.integration_tests.pages import changepasswordpage
 
17
from openstack_dashboard.test.integration_tests.pages import pageobject
 
18
 
 
19
 
 
20
class SettingsPage(basepage.BasePage):
 
21
    DEFAULT_LANGUAGE = "en"
 
22
    DEFAULT_TIMEZONE = "UTC"
 
23
    DEFAULT_PAGESIZE = "20"
 
24
    DEFAULT_SETTINGS = {
 
25
        "language": DEFAULT_LANGUAGE,
 
26
        "timezone": DEFAULT_TIMEZONE,
 
27
        "pagesize": DEFAULT_PAGESIZE
 
28
    }
 
29
 
 
30
    _change_password_tab_locator = (by.By.CSS_SELECTOR,
 
31
                                    'a[href*="/settings/password/"]')
 
32
 
 
33
    def __init__(self, driver, conf):
 
34
        super(SettingsPage, self).__init__(driver, conf)
 
35
        self._page_title = "User Settings"
 
36
 
 
37
    @property
 
38
    def modal(self):
 
39
        return SettingsPage.UserSettingsModal(self.driver, self.conf)
 
40
 
 
41
    @property
 
42
    def changepassword(self):
 
43
        return changepasswordpage.ChangePasswordPage(self.driver, self.conf)
 
44
 
 
45
    @property
 
46
    def change_password_tab(self):
 
47
        return self.get_element(*self._change_password_tab_locator)
 
48
 
 
49
    def change_language(self, lang=DEFAULT_LANGUAGE):
 
50
        self.select_dropdown_by_value(lang,
 
51
                                      self.modal.language_selection)
 
52
        self.modal.click_on_save_button()
 
53
 
 
54
    def change_timezone(self, timezone=DEFAULT_TIMEZONE):
 
55
        self.select_dropdown_by_value(timezone,
 
56
                                      self.modal.timezone_selection)
 
57
        self.modal.click_on_save_button()
 
58
 
 
59
    def change_pagesize(self, size=DEFAULT_PAGESIZE):
 
60
        self.fill_field_element(size, self.modal.pagesize)
 
61
        self.modal.click_on_save_button()
 
62
 
 
63
    def return_to_default_settings(self):
 
64
        self.change_language()
 
65
        self.change_timezone()
 
66
        self.change_pagesize()
 
67
 
 
68
    def go_to_change_password_page(self):
 
69
        self.change_password_tab.click()
 
70
        return changepasswordpage.ChangePasswordPage(self.driver, self.conf)
 
71
 
 
72
    class UserSettingsModal(pageobject.PageObject):
 
73
        _language_selection_locator = (by.By.CSS_SELECTOR,
 
74
                                       'select#id_language')
 
75
        _timezone_selection_locator = (by.By.CSS_SELECTOR,
 
76
                                       'select#id_timezone')
 
77
        _items_per_page_input_locator = (by.By.CSS_SELECTOR,
 
78
                                         'input#id_pagesize')
 
79
        _save_submit_button_locator = (by.By.CSS_SELECTOR,
 
80
                                       'div.modal-footer button.btn')
 
81
 
 
82
        @property
 
83
        def language_selection(self):
 
84
            return self.get_element(*self._language_selection_locator)
 
85
 
 
86
        @property
 
87
        def timezone_selection(self):
 
88
            return self.get_element(*self._timezone_selection_locator)
 
89
 
 
90
        @property
 
91
        def pagesize(self):
 
92
            return self.get_element(*self._items_per_page_input_locator)
 
93
 
 
94
        @property
 
95
        def save_button(self):
 
96
            return self.get_element(*self._save_submit_button_locator)
 
97
 
 
98
        def click_on_save_button(self):
 
99
            self.save_button.click()