cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
cm_templates_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_templates_test
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 31.01.2013
27 #
28 
29 from wi.tests import WiTestCase
30 import random
31 import unittest
32 
33 
34 class CMTemplatesTests(WiTestCase, unittest.TestCase):
35  def _test_add_template(self):
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/templates/")
43 
44  self.wait_for_text("//table[@id='item-list']/tfoot/tr/td/ul/li/a", ["Create a new template"])
45 
46  driver.find_element_by_link_text("Create a new template").click()
47 
48  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
49 
50  name = "witest_template" + str(random.randint(1, 100000))
51  driver.find_element_by_id("id_name").clear()
52  driver.find_element_by_id("id_name").send_keys(name)
53  driver.find_element_by_id("id_description").clear()
54  driver.find_element_by_id("id_description").send_keys("witest")
55  driver.find_element_by_id("id_points").clear()
56  driver.find_element_by_id("id_points").send_keys("1")
57  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
58 
59  self.wait_for_message(["You have successfully created a template."])
60 
61  driver.find_element_by_link_text("Logout from CM").click()
62  driver.find_element_by_link_text("Logout").click()
63 
64  return name
65 
66  def _test_edit_template(self, name):
67  driver = self.driver
68  self.base_url = self.TEST_SERVER
69 
70  self.login_testuser(self.TEST_admin_cm)
71  self.login_cm_testuser()
72 
73  driver.get(self.base_url + "/admin_cm/templates/")
74 
75  self.wait_for_text("//table[@id='item-list']/tbody", [name])
76 
77  self.menu_click("Name", name, "Edit")
78 
79  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
80 
81  newname = "new_witest_template" + str(random.randint(1, 100000))
82  driver.find_element_by_id("id_name").clear()
83  driver.find_element_by_id("id_name").send_keys(newname)
84  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
85 
86  self.wait_for_message(["You have successfully edited selected template."])
87 
88  driver.find_element_by_link_text("Logout from CM").click()
89  driver.find_element_by_link_text("Logout").click()
90 
91  return newname
92 
93  def _test_remove_template(self, name):
94  driver = self.driver
95  self.base_url = self.TEST_SERVER
96 
97  self.login_testuser(self.TEST_admin_cm)
98  self.login_cm_testuser()
99 
100  driver.get(self.base_url + "/admin_cm/templates/")
101 
102  self.wait_for_text("//table[@id='item-list']/tbody", [name])
103 
104  self.menu_click("Name", name, "Delete")
105 
106  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to delete template"])
107 
108  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
109 
110  self.wait_for_message(["You have successfully deleted template"])
111 
112  driver.find_element_by_link_text("Logout from CM").click()
113  driver.find_element_by_link_text("Logout").click()
114 
115  def _test_send_request(self, name):
116  driver = self.driver
117  self.base_url = self.TEST_SERVER
118 
119  self.login_testuser(self.TEST_admin_cm)
120  self.login_cm_testuser()
121 
122  driver.get(self.base_url + "/admin_cm/templates/")
123 
124  self.wait_for_text("//table[@id='item-list']/tbody", [name])
125 
126  self.menu_click("Name", name, "Edit")
127 
128  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Name"])
129 
130  newname = "new_witest_template" + str(random.randint(1, 100000))
131  driver.find_element_by_id("id_name").clear()
132  driver.find_element_by_id("id_name").send_keys(newname)
133  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
134 
135  self.wait_for_message(["You have successfully edited selected template."])
136 
137  driver.find_element_by_link_text("Logout from CM").click()
138  driver.find_element_by_link_text("Logout").click()
139 
140  return newname
141 
142  def test_1_simple(self):
143  name = self._test_add_template()
144  newname = self._test_edit_template(name)
145  self._test_remove_template(newname)
146