cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
account_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.account_test
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 12.10.2012
27 #
28 
29 from wi.tests import WiTestCase
30 import random
31 import unittest
32 
33 
34 class AccountTests(WiTestCase, unittest.TestCase):
35 
36  def _email_change(self, email):
37  driver = self.driver
38  self.base_url = self.TEST_SERVER
39 
40  self.login_testuser(self.TEST_USER)
41  driver.get(self.base_url + "/account/account_data/")
42 
43  self.wait_for_text("//div[@id='user-data']/fieldset[2]/a", ["Edit account data"])
44 
45  driver.find_element_by_link_text("Edit account data").click()
46  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div/span/label", ["Email address"])
47 
48  driver.find_element_by_id("id_email").clear()
49  driver.find_element_by_id("id_email").send_keys(email)
50  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
51 
53  email = str(random.randint(1, 100000)) + '@witest.pl'
54  self._email_change(email)
55  self.wait_for_text("//div[@id='user-data']/fieldset/div[3]/span[2]", [email])
56 
58  self._email_change('')
59  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div[1]/ul/li", ["This field is required."])
60 
62  self._email_change('aaaaaaaaa.de')
63  self.wait_for_text("//div[@id='dialog-div']/form/div/fieldset/div[1]/ul/li", ["Enter a valid email address."])
64 
66  driver = self.driver
67  self.base_url = self.TEST_SERVER
68 
69  self.login_testuser(self.TEST_USER)
70  driver.get(self.base_url + "/account/password_change/")
71  self.wait_for_text("//div[@id='content']/div[3]/div/div[5]/div[2]/p", ["Please enter your old password"])
72 
73  driver.find_element_by_id("id_old_password").clear()
74  driver.find_element_by_id("id_old_password").send_keys(self.TEST_USER['password'])
75  driver.find_element_by_id("id_new_password1").clear()
76  driver.find_element_by_id("id_new_password1").send_keys(self.TEST_USER['password'])
77  driver.find_element_by_id("id_new_password2").clear()
78  driver.find_element_by_id("id_new_password2").send_keys(self.TEST_USER['password'])
79 
80  driver.find_element_by_css_selector("input.big_button").click()
81  self.wait_for_text("//div[@id='content']/div[3]/div/div[5]/div[2]/p", ["Your password has been changed."])
82 
83  def test_account_chart(self):
84  driver = self.driver
85  self.base_url = self.TEST_SERVER
86 
87  self.login_testuser(self.TEST_USER)
88  driver.get(self.base_url + "/account/account_quotas/")
89  self.wait_for_text("//div[@id='user-data']/fieldset[2]/a", ["Point usage chart"])
90 
91  driver.find_element_by_link_text("Point usage chart").click()
92  self.wait_for_text("//div[@id='flotChart']", ["monthly point limit"])
93 
94  def test_show_ec2_key(self):
95  driver = self.driver
96  self.base_url = self.TEST_SERVER
97 
98  self.login_testuser(self.TEST_USER)
99  driver.get(self.base_url + "/account/account_data/")
100  driver.find_element_by_link_text("Show").click()
101 
102  self.wait_for_text("//span[@id='ui-dialog-title-dialog-div']", ["Copy to clipboard:"])
103  self.assertEqual("b444ac06613fc8d63795be9ad0beaf55011936ac", driver.find_element_by_css_selector("textarea").get_attribute("value"))
104