cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
cm_user_test.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 # -*- coding: utf-8 -*-
21 ##
22 # @package src.wi.tests.cm_users
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 22.03.2013
27 #
28 
29 from wi.tests import WiTestCase
30 import unittest
31 
32 
33 class CMUsersTests(WiTestCase, unittest.TestCase):
34  def _test_set_admin(self):
35  driver = self.driver
36  self.base_url = self.TEST_SERVER
37 
38  self.login_testuser(self.TEST_admin_cm)
39  self.login_cm_testuser()
40 
41  driver.get(self.base_url + "/admin_cm/users/")
42 
43  self.wait_for_text("//table[@id='item-list']/tbody", ["test_user"])
44 
45  self.menu_click("Username", "test_user", "Set admin")
46 
47  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to promote user"])
48 
49  driver.find_element_by_id("id_new_password").clear()
50  driver.find_element_by_id("id_new_password").send_keys("cokolwiek")
51  driver.find_element_by_id("id_password2").clear()
52  driver.find_element_by_id("id_password2").send_keys("cokolwiek")
53 
54  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
55 
56  self.wait_for_message(["You have successfully promoted user "])
57 
58  driver.find_element_by_link_text("Logout from CM").click()
59  driver.find_element_by_link_text("Logout").click()
60 
61  def _test_unset_admin(self):
62  driver = self.driver
63  self.base_url = self.TEST_SERVER
64 
65  self.login_testuser(self.TEST_admin_cm)
66  self.login_cm_testuser()
67 
68  driver.get(self.base_url + "/admin_cm/users/")
69 
70  self.wait_for_text("//table[@id='item-list']/tbody", ["test_user"])
71 
72  self.menu_click("Username", "test_user", "Unset admin")
73 
74  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to demote administrator"])
75 
76  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
77 
78  self.wait_for_message(["You have successfully demoted administrator"])
79 
80  driver.find_element_by_link_text("Logout from CM").click()
81  driver.find_element_by_link_text("Logout").click()
82 
83  def _test_change_quota(self):
84  driver = self.driver
85  self.base_url = self.TEST_SERVER
86 
87  self.login_testuser(self.TEST_admin_cm)
88  self.login_cm_testuser()
89 
90  driver.get(self.base_url + "/admin_cm/users/")
91  self.wait_for_text("//table[@id='item-list']/tbody", ["test_user"])
92 
93  self.cell_click("Username", "test_user", action_name="", element="input")
94 
95  driver.find_element_by_xpath("//li[@id='group_action']/a").click()
96 
97  self.wait_for_text("//ul[@id='context-menu-list']/li", ["Change quota"])
98 
99  driver.find_element_by_xpath("//ul[@id='context-menu-list']/li").click()
100 
101  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span", ["Cpu Total"])
102 
103  driver.find_element_by_id("id_cpu").clear()
104  driver.find_element_by_id("id_cpu").send_keys("12")
105 
106  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
107 
108  self.wait_for_message(["You have successfully changed quota."])
109 
110  driver.find_element_by_link_text("Logout from CM").click()
111  driver.find_element_by_link_text("Logout").click()
112 
113  def _test_change_quota_account(self):
114  driver = self.driver
115  self.base_url = self.TEST_SERVER
116 
117  self.login_testuser(self.TEST_admin_cm)
118  self.login_cm_testuser()
119 
120  driver.get(self.base_url + "/admin_cm/users/")
121 
122  self.wait_for_text("//table[@id='item-list']/tbody", ["test_user"])
123 
124  self.menu_click("Username", "test_user", "User account")
125 
126  self.wait_for_text("//div[@id='user-data']/fieldset/div/span[2]", ["test_user"])
127 
128  driver.find_element_by_link_text("Edit account quota").click()
129 
130  driver.find_element_by_id("id_cpu").clear()
131  driver.find_element_by_id("id_cpu").send_keys("20")
132 
133  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
134 
135  self.wait_for_message(["You have successfully changed the user's quota."])
136 
137  driver.find_element_by_link_text("Logout from CM").click()
138  driver.find_element_by_link_text("Logout").click()
139 
140  def test_1_simple(self):
141  self._test_set_admin()
142  self._test_unset_admin()
143  self._test_change_quota()
145