cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
groups_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.groups_test
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 05.03.2013
27 #
28 
29 from wi.tests import WiTestCase
30 import unittest
31 import random
32 
33 
34 class GroupsTests(WiTestCase, unittest.TestCase):
35  @staticmethod
36  def _test_create_group(self):
37  driver = self.driver
38  self.base_url = self.TEST_SERVER
39 
40  self.login_testuser(self.TEST_USER)
41 
42  driver.get(self.base_url + "/groups/my_groups/")
43 
44  self.wait_for_text("//table[@id='item-list']/tfoot/tr/td/ul/li/a", ["Create a new group"])
45 
46  driver.find_element_by_link_text("Create a new group").click()
47 
48  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
49 
50  name = "witest_group" + str(random.randint(1, 100000))
51 
52  driver.find_element_by_id("id_name").clear()
53  driver.find_element_by_id("id_name").send_keys(name)
54  driver.find_element_by_id("id_description").clear()
55  driver.find_element_by_id("id_description").send_keys(name)
56  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
57 
58  self.wait_for_message(["You have successfully created a group."])
59 
60  driver.find_element_by_link_text("Logout").click()
61 
62  return name
63 
64  def _test_edit_group(self, name):
65  driver = self.driver
66  self.base_url = self.TEST_SERVER
67 
68  self.login_testuser(self.TEST_USER)
69 
70  driver.get(self.base_url + "/groups/my_groups/")
71 
72  self.wait_for_text("//table[@id='item-list']/tbody", [name])
73 
74  self.menu_click("Name", name, "Edit")
75 
76  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
77 
78  newname = "new_witest_group" + str(random.randint(1, 100000))
79  driver.find_element_by_id("id_name").clear()
80  driver.find_element_by_id("id_name").send_keys(newname)
81  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
82 
83  self.wait_for_message(["You have successfully edited selected group."])
84 
85  driver.find_element_by_link_text("Logout").click()
86 
87  return newname
88 
89  @staticmethod
90  def _test_remove_group(self, name, who=None):
91  driver = self.driver
92  self.base_url = self.TEST_SERVER
93  if who != None:
94  self.login_testuser(who)
95  else:
96  self.login_testuser(self.TEST_admin_cm)
97 
98  driver.get(self.base_url + "/groups/my_groups/")
99 
100  self.wait_for_text("//table[@id='item-list']/tbody", [name])
101 
102  self.menu_click("Name", name, "Remove")
103 
104  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to delete this group?"])
105 
106  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
107 
108  self.wait_for_message(["You have successfully deleted this group."])
109 
110  driver.find_element_by_link_text("Logout").click()
111 
112  def _test_send_request(self, name):
113  driver = self.driver
114  self.base_url = self.TEST_SERVER
115 
116  self.login_testuser(self.TEST_admin_cm)
117 
118  driver.get(self.base_url + "/groups/list_groups/")
119 
120  self.wait_for_text("//table[@id='item-list']/tbody", [name])
121 
122  self.menu_click("Name", name, "Send request")
123 
124  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to send a request?"])
125 
126  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
127 
128  self.wait_for_message(["You have successfully sent a request"])
129 
130  driver.find_element_by_link_text("Logout").click()
131 
132  def _test_cancel_request(self, name):
133  driver = self.driver
134  self.base_url = self.TEST_SERVER
135 
136  self.login_testuser(self.TEST_USER)
137 
138  driver.get(self.base_url + "/groups/my_groups/")
139 
140  self.wait_for_text("//table[@id='item-list']/tbody", [name])
141 
142  self.menu_click("Name", name, "Show details")
143 
144  self.wait_for_text("//table[@id='item-list']/tbody", ['TestCMAdmin'])
145 
146  self.menu_click("Name", 'TestCMAdmin', "Cancel")
147 
148  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to cancel request from user"])
149 
150  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
151 
152  self.wait_for_message(["You have successfully canceled request from user "])
153 
154  driver.find_element_by_link_text("Logout").click()
155 
156  def _test_accept_request(self, name):
157  driver = self.driver
158  self.base_url = self.TEST_SERVER
159 
160  self.login_testuser(self.TEST_USER)
161 
162  driver.get(self.base_url + "/groups/my_groups/")
163 
164  self.wait_for_text("//table[@id='item-list']/tbody", [name])
165 
166  self.menu_click("Name", name, "Show details")
167 
168  self.wait_for_text("//table[@id='item-list']/tbody", ['TestCMAdmin'])
169 
170  self.menu_click("Name", 'TestCMAdmin', "Accept")
171 
172  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to add user"])
173 
174  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
175 
176  self.wait_for_message(["You have successfully added user "])
177 
178  driver.find_element_by_link_text("Logout").click()
179 
180  def _test_make_leader(self, name):
181  driver = self.driver
182  self.base_url = self.TEST_SERVER
183 
184  self.login_testuser(self.TEST_USER)
185 
186  driver.get(self.base_url + "/groups/my_groups/")
187 
188  self.wait_for_text("//table[@id='item-list']/tbody", [name])
189 
190  self.menu_click("Name", name, "Show details")
191 
192  self.wait_for_text("//table[@id='item-list']/tbody", ['TestCMAdmin'])
193 
194  self.menu_click("Name", 'TestCMAdmin', "Make leader")
195 
196  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to change group leader to user "])
197 
198  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
199 
200  self.wait_for_text("//div[@class='b_innerContainer']/div[2]/div/p", ["TestCMAdmin"])
201 
202  driver.find_element_by_link_text("Logout").click()
203 
204  def _test_remove_user(self, name):
205  driver = self.driver
206  self.base_url = self.TEST_SERVER
207 
208  self.login_testuser(self.TEST_admin_cm)
209 
210  driver.get(self.base_url + "/groups/my_groups/")
211 
212  self.wait_for_text("//table[@id='item-list']/tbody", [name])
213 
214  self.menu_click("Name", name, "Show details")
215 
216  self.wait_for_text("//table[@id='item-list']/tbody", ['Test'])
217 
218  self.menu_click("Name", 'TestUser', "Remove")
219 
220  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to remove user"])
221 
222  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
223 
224  self.wait_for_message(["You have successfully removed user"])
225 
226  driver.find_element_by_link_text("Logout").click()
227 
228  def test_1_all(self):
229  name = self._test_create_group(self)
230  newname = self._test_edit_group(name)
231  self._test_send_request(newname)
232  self._test_cancel_request(newname)
233  self._test_send_request(newname)
234  self._test_accept_request(newname)
235  self._test_make_leader(newname)
236  self._test_remove_user(newname)
237  self._test_remove_group(self, newname)
238