cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
test_clean.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.test_clean
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 20.02.2013
27 #
28 
29 from wi.tests import WiTestCase
30 import cm_images_test
31 import unittest
32 
33 
34 class CleanTests(WiTestCase, unittest.TestCase):
35  def _test_erase_vms(self, search_text):
36  driver = self.driver
37  self.base_url = self.TEST_SERVER
38 
39  self.login_testuser(self.TEST_admin_cm)
40  self.login_cm_testuser()
41 
42  driver.get(self.base_url + "/admin_cm/vms/")
43 
44  driver.find_element_by_xpath("//div[@id='searchBox']/input").clear()
45  driver.find_element_by_xpath("//div[@id='searchBox']/input").send_keys(search_text)
46 
47  if self.wait_for_text("//table[@id='item-list']/tbody", [search_text], fail=False) == False:
48  driver.find_element_by_link_text("Logout from CM").click()
49  driver.find_element_by_link_text("Logout").click()
50  return False
51 
52  driver.find_element_by_id("auto-refresh").click()
53 
54  driver.find_element_by_xpath("//table[@id='item-list']/thead/tr/td/input").click()
55 
56  driver.find_element_by_xpath("//li[@id='group_action']/a").click()
57 
58  self.wait_for_text("//ul[@id='context-menu-list']/li", ["Erase"])
59 
60  driver.find_element_by_xpath("//ul[@id='context-menu-list']/li[2]").click()
61 
62  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to erase"])
63 
64  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
65 
66  self.wait_for_message(["successfully erased"])
67 
68  driver.find_element_by_link_text("Logout from CM").click()
69  driver.find_element_by_link_text("Logout").click()
70 
71  def test_clean_images(self):
72  resp = True
73  while(resp):
74  resp = cm_images_test.CMImagesTests._test_remove_image(self, 'witest_image', fail=False)
75  resp = True
76  while(resp):
77  resp = cm_images_test.CMImagesTests._test_remove_image(self, 'witest_cm_image', fail=False)
78  resp = True
79  while(resp):
80  resp = cm_images_test.CMImagesTests._test_remove_image(self, 'failed', column='State', fail=False)
81  resp = True
82  while(resp):
83  resp = cm_images_test.CMImagesTests._test_remove_image(self, 'adding', column='State', fail=False)
84 
85  def test_clean_isos(self):
86  resp = True
87  while(resp):
88  resp = cm_images_test.CMImagesTests._test_remove_iso(self, 'witest_iso', fail=False)
89  resp = True
90  while(resp):
91  resp = cm_images_test.CMImagesTests._test_remove_iso(self, 'failed', column='Size', fail=False)
92  resp = True
93  while(resp):
94  resp = cm_images_test.CMImagesTests._test_remove_iso(self, '%', column='Size', fail=False)
95 
96  def test_clean_disks(self):
97  resp = True
98  while(resp):
99  resp = cm_images_test.CMImagesTests._test_remove_disk(self, 'witest_disk', fail=False)
100  resp = True
101  while(resp):
102  resp = cm_images_test.CMImagesTests._test_remove_disk(self, 'failed', column='Size', fail=False)
103  resp = True
104  while(resp):
105  resp = cm_images_test.CMImagesTests._test_remove_disk(self, '%', column='Size', fail=False)
106 
107  def test_clean_vms(self):
108  self._test_erase_vms('failed')
109  self._test_erase_vms('witest_vm')
110