cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
cm_images_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_images_test
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 09.01.2013
27 #
28 
29 from wi.tests import WiTestCase
30 import images_test
31 import random
32 import resources_test
33 import unittest
34 
35 
36 class CMImagesTests(WiTestCase, unittest.TestCase):
37 
38  def _test_register_image(self):
39  driver = self.driver
40  self.base_url = self.TEST_SERVER
41 
42  self.login_testuser(self.TEST_admin_cm)
43  self.login_cm_testuser()
44 
45  driver.get(self.base_url + "/admin_cm/images/")
46 
47  self.wait_for_text("//table[@id='item-list']/tfoot/tr/td/ul/li/a", ["Register image"])
48 
49  driver.find_element_by_link_text("Register image").click()
50 
51  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
52 
53  name = "witest_cm_image" + str(random.randint(1, 100000))
54  driver.find_element_by_id("id_name").clear()
55  driver.find_element_by_id("id_name").send_keys(name)
56  driver.find_element_by_id("id_description").clear()
57  driver.find_element_by_id("id_description").send_keys(self.iso)
58  driver.find_element_by_id("id_path").clear()
59  driver.find_element_by_id("id_path").send_keys(self.iso)
60  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
61 
62  self.wait_for_message(["You have successfully added an image."])
63 
64  driver.find_element_by_link_text("Logout from CM").click()
65  driver.find_element_by_link_text("Logout").click()
66 
67  return name
68 
69  def _test_register_image_empty(self):
70  driver = self.driver
71  self.base_url = self.TEST_SERVER
72 
73  self.login_testuser(self.TEST_admin_cm)
74  self.login_cm_testuser()
75 
76  driver.get(self.base_url + "/admin_cm/images/")
77 
78  self.wait_for_text("//table[@id='item-list']/tfoot/tr/td/ul/li/a", ["Register image"])
79 
80  driver.find_element_by_link_text("Register image").click()
81 
82  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
83 
84  driver.find_element_by_id("id_name").clear()
85  driver.find_element_by_id("id_description").clear()
86  driver.find_element_by_id("id_path").clear()
87  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
88  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/ul/li", ["This field is required."])
89  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset[2]/div[2]/ul/li", ["This field is required."])
90  driver.find_element_by_css_selector("button.cancel-button.mid_button").click()
91 
92  driver.find_element_by_link_text("Logout from CM").click()
93  driver.find_element_by_link_text("Logout").click()
94 
95  def _test_edit_image(self, name):
96  driver = self.driver
97  self.base_url = self.TEST_SERVER
98 
99  self.login_testuser(self.TEST_admin_cm)
100  self.login_cm_testuser()
101 
102  driver.get(self.base_url + "/admin_cm/images/")
103 
104  self.wait_for_text("//table[@id='item-list']/tbody", [name])
105 
106  self.menu_click("Name", name, "Edit", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
107 
108  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
109 
110  newname = "new_witest_cm_image" + str(random.randint(1, 100000))
111  driver.find_element_by_id("id_name").clear()
112  driver.find_element_by_id("id_name").send_keys(newname)
113  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
114 
115  self.wait_for_message(["You have successfully edited selected image."])
116 
117  driver.find_element_by_link_text("Logout from CM").click()
118  driver.find_element_by_link_text("Logout").click()
119 
120  return newname
121 
122  def _test_edit_image_empty(self, name):
123  driver = self.driver
124  self.base_url = self.TEST_SERVER
125 
126  self.login_testuser(self.TEST_admin_cm)
127  self.login_cm_testuser()
128 
129  driver.get(self.base_url + "/admin_cm/images/")
130 
131  self.wait_for_text("//table[@id='item-list']/tbody", [name])
132 
133  self.menu_click("Name", name, "Edit", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
134 
135  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
136 
137  driver.find_element_by_id("id_name").clear()
138  driver.find_element_by_id("id_description").clear()
139  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
140  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/ul/li", ["This field is required."])
141  driver.find_element_by_css_selector("button.cancel-button.mid_button").click()
142 
143  driver.find_element_by_link_text("Logout from CM").click()
144  driver.find_element_by_link_text("Logout").click()
145 
146  def _test_copy_image(self, name):
147  driver = self.driver
148  self.base_url = self.TEST_SERVER
149 
150  self.login_testuser(self.TEST_admin_cm)
151  self.login_cm_testuser()
152 
153  driver.get(self.base_url + "/admin_cm/images/")
154 
155  self.wait_for_text("//table[@id='item-list']/tbody", [name])
156 
157  self.menu_click("Name", name, "Copy", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
158 
159  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["User"])
160 
161  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
162 
163  self.wait_for_message(["copied."])
164 
165  driver.find_element_by_link_text("Logout from CM").click()
166  driver.find_element_by_link_text("Logout").click()
167 
168  @staticmethod
169  def _test_remove_image(self, name, fail=True, column="Name"):
170  driver = self.driver
171  self.base_url = self.TEST_SERVER
172 
173  self.login_testuser(self.TEST_admin_cm)
174  self.login_cm_testuser()
175 
176  driver.get(self.base_url + "/admin_cm/images/")
177 
178  if self.wait_for_text("//table[@id='item-list']/tbody", [name], fail=fail) == False:
179  driver.find_element_by_link_text("Logout from CM").click()
180  driver.find_element_by_link_text("Logout").click()
181  return False
182 
183  self.menu_click(column, name, "Delete")
184 
185  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to delete image"])
186 
187  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
188 
189  self.wait_for_message(["You have successfully deleted image"])
190 
191  driver.find_element_by_link_text("Logout from CM").click()
192  driver.find_element_by_link_text("Logout").click()
193 
194  if fail == False:
195  return True
196 
197  def _test_public_image(self, name):
198  driver = self.driver
199  self.base_url = self.TEST_SERVER
200 
201  self.login_testuser(self.TEST_admin_cm)
202  self.login_cm_testuser()
203 
204  driver.get(self.base_url + "/admin_cm/images/")
205 
206  self.wait_for_text("//table[@id='item-list']/tbody", [name])
207 
208  self.menu_click("Name", name, "Move to public images", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
209 
210  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to make image"])
211 
212  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
213 
214  self.wait_for_message(["You have successfully changed type of image"])
215 
216  driver.find_element_by_link_text("Logout from CM").click()
217  driver.find_element_by_link_text("Logout").click()
218 
219  def _test_private_image(self, name):
220  driver = self.driver
221  self.base_url = self.TEST_SERVER
222 
223  self.login_testuser(self.TEST_admin_cm)
224  self.login_cm_testuser()
225 
226  driver.get(self.base_url + "/admin_cm/images/")
227 
228  self.wait_for_text("//table[@id='item-list']/tbody", [name])
229 
230  self.menu_click("Name", name, "Move to private images", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
231 
232  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to make image"])
233 
234  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
235 
236  self.wait_for_message(["You have successfully changed type of image"])
237 
238  driver.find_element_by_link_text("Logout from CM").click()
239  driver.find_element_by_link_text("Logout").click()
240 
241  def _test_edit_disk(self, name):
242  driver = self.driver
243  self.base_url = self.TEST_SERVER
244 
245  self.login_testuser(self.TEST_admin_cm)
246  self.login_cm_testuser()
247 
248  driver.get(self.base_url + "/admin_cm/disks/")
249 
250  self.wait_for_text("//table[@id='item-list']/tbody", [name])
251 
252  self.menu_click("Name", name, "Edit", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
253 
254  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Disk name"])
255 
256  newname = "new_witest_disk" + str(random.randint(1, 100000))
257  driver.find_element_by_id("id_name").clear()
258  driver.find_element_by_id("id_name").send_keys(newname)
259  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
260 
261  self.wait_for_message(["You have successfully edited selected disk."])
262 
263  driver.find_element_by_link_text("Logout from CM").click()
264  driver.find_element_by_link_text("Logout").click()
265 
266  return newname
267 
268  def _test_edit_disk_empty(self, name):
269  driver = self.driver
270  self.base_url = self.TEST_SERVER
271 
272  self.login_testuser(self.TEST_admin_cm)
273  self.login_cm_testuser()
274 
275  driver.get(self.base_url + "/admin_cm/disks/")
276 
277  self.wait_for_text("//table[@id='item-list']/tbody", [name])
278 
279  self.menu_click("Name", name, "Edit", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
280 
281  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Disk name"])
282 
283  driver.find_element_by_id("id_name").clear()
284  driver.find_element_by_id("id_description").clear()
285  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
286  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/ul/li", ["This field is required."])
287  driver.find_element_by_css_selector("button.cancel-button.mid_button").click()
288 
289  driver.find_element_by_link_text("Logout from CM").click()
290  driver.find_element_by_link_text("Logout").click()
291 
292  def _test_copy_disk(self, name):
293  driver = self.driver
294  self.base_url = self.TEST_SERVER
295 
296  self.login_testuser(self.TEST_admin_cm)
297  self.login_cm_testuser()
298 
299  driver.get(self.base_url + "/admin_cm/disks/")
300 
301  self.wait_for_text("//table[@id='item-list']/tbody", [name])
302 
303  self.menu_click("Name", name, "Copy", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
304 
305  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["User"])
306 
307  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
308 
309  self.wait_for_message(["copied."])
310 
311  driver.find_element_by_link_text("Logout from CM").click()
312  driver.find_element_by_link_text("Logout").click()
313 
314  @staticmethod
315  def _test_remove_disk(self, name, column="Name", fail=True):
316  driver = self.driver
317  self.base_url = self.TEST_SERVER
318 
319  self.login_testuser(self.TEST_admin_cm)
320  self.login_cm_testuser()
321 
322  driver.get(self.base_url + "/admin_cm/disks/")
323 
324  if self.wait_for_text("//table[@id='item-list']/tbody", [name], fail=fail) == False:
325  driver.find_element_by_link_text("Logout from CM").click()
326  driver.find_element_by_link_text("Logout").click()
327  return False
328 
329  self.menu_click(column, name, "Delete")
330 
331  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to delete disk"])
332 
333  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
334 
335  self.wait_for_message(["You have successfully deleted disk volume"])
336 
337  driver.find_element_by_link_text("Logout from CM").click()
338  driver.find_element_by_link_text("Logout").click()
339 
340  if fail == False:
341  return True
342 
343  def _test_edit_iso(self, name):
344  driver = self.driver
345  self.base_url = self.TEST_SERVER
346 
347  self.login_testuser(self.TEST_admin_cm)
348  self.login_cm_testuser()
349 
350  driver.get(self.base_url + "/admin_cm/iso/")
351 
352  self.wait_for_text("//table[@id='item-list']/tbody", [name])
353 
354  self.menu_click("Name", name, "Edit", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
355 
356  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["ISO image name"])
357 
358  newname = "new_witest_iso" + str(random.randint(1, 100000))
359  driver.find_element_by_id("id_name").clear()
360  driver.find_element_by_id("id_name").send_keys(newname)
361  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
362 
363  self.wait_for_message(["You have successfully edited selected ISO image."])
364 
365  driver.find_element_by_link_text("Logout from CM").click()
366  driver.find_element_by_link_text("Logout").click()
367 
368  return newname
369 
370  def _test_edit_iso_empty(self, name):
371  driver = self.driver
372  self.base_url = self.TEST_SERVER
373 
374  self.login_testuser(self.TEST_admin_cm)
375  self.login_cm_testuser()
376 
377  driver.get(self.base_url + "/admin_cm/iso/")
378 
379  self.wait_for_text("//table[@id='item-list']/tbody", [name])
380 
381  self.menu_click("Name", name, "Edit", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
382 
383  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["ISO image name"])
384 
385  driver.find_element_by_id("id_name").clear()
386  driver.find_element_by_id("id_description").clear()
387  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
388  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/ul/li", ["This field is required."])
389  driver.find_element_by_css_selector("button.cancel-button.mid_button").click()
390 
391  driver.find_element_by_link_text("Logout from CM").click()
392  driver.find_element_by_link_text("Logout").click()
393 
394  def _test_copy_iso(self, name):
395  driver = self.driver
396  self.base_url = self.TEST_SERVER
397 
398  self.login_testuser(self.TEST_admin_cm)
399  self.login_cm_testuser()
400 
401  driver.get(self.base_url + "/admin_cm/iso/")
402 
403  self.wait_for_text("//table[@id='item-list']/tbody", [name])
404 
405  self.menu_click("Name", name, "Copy", {"dict": {"Size": "B"}, "path": "//table[@id='item-list']/tbody"})
406 
407  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["User"])
408 
409  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
410 
411  self.wait_for_message(["copied."])
412 
413  driver.find_element_by_link_text("Logout from CM").click()
414  driver.find_element_by_link_text("Logout").click()
415 
416  @staticmethod
417  def _test_remove_iso(self, name, column="Name", fail=True):
418  driver = self.driver
419  self.base_url = self.TEST_SERVER
420 
421  self.login_testuser(self.TEST_admin_cm)
422  self.login_cm_testuser()
423 
424  driver.get(self.base_url + "/admin_cm/iso/")
425 
426  if self.wait_for_text("//table[@id='item-list']/tbody", [name], fail=fail) == False:
427  driver.find_element_by_link_text("Logout from CM").click()
428  driver.find_element_by_link_text("Logout").click()
429  return False
430 
431  self.menu_click(column, name, "Delete")
432 
433  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to delete ISO image"])
434 
435  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
436 
437  self.wait_for_message(["You have successfully deleted ISO image"])
438 
439  driver.find_element_by_link_text("Logout from CM").click()
440  driver.find_element_by_link_text("Logout").click()
441 
442  if fail == False:
443  return True
444 
445  def test_1_simple(self):
446  name = self._test_register_image()
447  newname = self._test_edit_image(name)
448  self._test_copy_image(newname)
449  self._test_remove_image(self, newname)
450 
451  def test_2_simple(self):
452  name = images_test.ImagesTests._test_upload_image_private(self)
453  newname = self._test_edit_image(name)
454  self._test_copy_image(newname)
455  self._test_remove_image(self, newname)
456  self._test_remove_image(self, newname)
457 
459  name = self._test_register_image()
460  self._test_public_image(name)
461  self._test_private_image(name)
462  self._test_remove_image(self, name)
463 
465  name = resources_test.ResourcesTests._test_create_disk(self)
466  newname = self._test_edit_disk(name)
467  self._test_copy_disk(newname)
468  self._test_remove_disk(self, newname)
469  self._test_remove_disk(self, newname)
470 
471  def test_5_simple_iso(self):
472  name = resources_test.ResourcesTests._test_upload_iso(self)
473  newname = self._test_edit_iso(name)
474  self._test_copy_iso(newname)
475  self._test_remove_iso(self, newname)
476  self._test_remove_iso(self, newname)
477 
480 
482  name = self._test_register_image()
483  self._test_edit_image_empty(name)
484  self._test_remove_image(self, name)
485 
487  name = resources_test.ResourcesTests._test_create_disk(self)
488  self._test_edit_disk_empty(name)
489  self._test_remove_disk(self, name)
490 
492  name = resources_test.ResourcesTests._test_upload_iso(self)
493  self._test_edit_iso_empty(name)
494  self._test_remove_iso(self, name)
495