Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
01890687
authored
Apr 01, 2015
by
Csók Tamás
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
selenium: corrected test cases with logging and error handling
parent
c2394baa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
circle/dashboard/tests/selenium/basic_tests.py
+26
-0
No files found.
circle/dashboard/tests/selenium/basic_tests.py
View file @
01890687
...
@@ -16,7 +16,9 @@
...
@@ -16,7 +16,9 @@
#
#
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
datetime
import
datetime
import
logging
import
logging
from
sys
import
_getframe
import
random
import
random
import
re
import
re
import
urlparse
import
urlparse
...
@@ -52,7 +54,13 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -52,7 +54,13 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
@classmethod
@classmethod
def
setup_class
(
cls
):
def
setup_class
(
cls
):
logger
.
warning
(
"Selenium test started @
%(time)
s"
%
{
'time'
:
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)})
if
conf
.
create_user
:
if
conf
.
create_user
:
logger
.
warning
(
"Creating selenium test user
%(name)
s:
%(password)
s"
%
{
'name'
:
conf
.
client_name
,
'password'
:
conf
.
random_pass
})
cls
.
_user
=
User
.
objects
.
create
(
username
=
conf
.
client_name
,
cls
.
_user
=
User
.
objects
.
create
(
username
=
conf
.
client_name
,
is_superuser
=
True
)
is_superuser
=
True
)
cls
.
_user
.
set_password
(
conf
.
random_pass
)
cls
.
_user
.
set_password
(
conf
.
random_pass
)
...
@@ -63,10 +71,18 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -63,10 +71,18 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
if
conf
.
create_user
:
if
conf
.
create_user
:
for
instance
in
Instance
.
objects
.
all
()
.
filter
(
for
instance
in
Instance
.
objects
.
all
()
.
filter
(
~
Q
(
status
=
u'DESTROYED'
),
owner
=
cls
.
_user
):
~
Q
(
status
=
u'DESTROYED'
),
owner
=
cls
.
_user
):
logger
.
warning
(
"Destroying the test virtual machine:
%(id)
s"
%
{
'id'
:
instance
.
pk
})
instance
.
destroy
(
system
=
True
)
instance
.
destroy
(
system
=
True
)
logger
.
warning
(
"Deleting test user
%(name)
s"
%
{
'name'
:
conf
.
client_name
})
cls
.
_user
.
delete
()
cls
.
_user
.
delete
()
logger
.
warning
(
"Selenium test finished @
%(time)
s"
%
{
'time'
:
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)})
def
test_01_login
(
self
):
def
test_01_login
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
title
=
'Dashboard | CIRCLE'
title
=
'Dashboard | CIRCLE'
location
=
'/dashboard/'
location
=
'/dashboard/'
self
.
login
()
self
.
login
()
...
@@ -78,6 +94,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -78,6 +94,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
'URL path is not equal with
%
s'
%
location
))
'URL path is not equal with
%
s'
%
location
))
def
test_02_add_template_rights
(
self
):
def
test_02_add_template_rights
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
template_pool
=
self
.
get_template_id
(
from_all
=
True
)
template_pool
=
self
.
get_template_id
(
from_all
=
True
)
if
len
(
template_pool
)
>
1
:
if
len
(
template_pool
)
>
1
:
...
@@ -118,6 +135,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -118,6 +135,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"Could not add user to template's ACL"
)
"Could not add user to template's ACL"
)
def
test_03_able_to_create_template
(
self
):
def
test_03_able_to_create_template
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
template_list
=
None
template_list
=
None
create_template
=
self
.
get_link_by_href
(
'/dashboard/template/choose/'
)
create_template
=
self
.
get_link_by_href
(
'/dashboard/template/choose/'
)
...
@@ -135,6 +153,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -135,6 +153,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"The create template list is empty"
))
"The create template list is empty"
))
def
test_04_create_base_template
(
self
):
def
test_04_create_base_template
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
created_template_id
=
self
.
get_template_id
(
created_template_id
=
self
.
get_template_id
(
self
.
create_base_template
())
self
.
create_base_template
())
...
@@ -146,6 +165,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -146,6 +165,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"Could not found the created template in the template list"
)
"Could not found the created template in the template list"
)
def
test_05_create_template_from_base
(
self
):
def
test_05_create_template_from_base
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
created_template_id
=
self
.
get_template_id
(
created_template_id
=
self
.
get_template_id
(
self
.
create_template_from_base
())
self
.
create_template_from_base
())
...
@@ -157,6 +177,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -157,6 +177,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"Could not found the created template in the template list"
)
"Could not found the created template in the template list"
)
def
test_06_delete_templates
(
self
):
def
test_06_delete_templates
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
success
=
False
success
=
False
self
.
login
()
self
.
login
()
for
template_id
in
self
.
template_ids
:
for
template_id
in
self
.
template_ids
:
...
@@ -175,6 +196,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -175,6 +196,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
success
,
"Could not delete (all) the test template(s)"
)
success
,
"Could not delete (all) the test template(s)"
)
def
test_07_able_to_create_vm
(
self
):
def
test_07_able_to_create_vm
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
vm_list
=
None
vm_list
=
None
create_vm_link
=
self
.
get_link_by_href
(
'/dashboard/vm/create/'
)
create_vm_link
=
self
.
get_link_by_href
(
'/dashboard/vm/create/'
)
...
@@ -192,12 +214,14 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -192,12 +214,14 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
self
.
assertGreater
(
len
(
vm_list
),
0
,
"The create VM list is empty"
))
self
.
assertGreater
(
len
(
vm_list
),
0
,
"The create VM list is empty"
))
def
test_08_create_vm
(
self
):
def
test_08_create_vm
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
pk
=
self
.
create_random_vm
()
pk
=
self
.
create_random_vm
()
self
.
vm_ids
.
append
(
pk
)
self
.
vm_ids
.
append
(
pk
)
self
.
assertIsNotNone
(
pk
,
"Can not create a VM"
)
self
.
assertIsNotNone
(
pk
,
"Can not create a VM"
)
def
test_09_vm_view_change
(
self
):
def
test_09_vm_view_change
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
expected_states
=
[
""
,
"none"
,
expected_states
=
[
""
,
"none"
,
"none"
,
""
,
"none"
,
""
,
...
@@ -209,6 +233,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -209,6 +233,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"The view mode does not change for VM listing"
)
"The view mode does not change for VM listing"
)
def
test_10_node_view_change
(
self
):
def
test_10_node_view_change
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
expected_states
=
[
""
,
"none"
,
expected_states
=
[
""
,
"none"
,
"none"
,
""
,
"none"
,
""
,
...
@@ -220,6 +245,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
...
@@ -220,6 +245,7 @@ class BasicSeleniumTests(SeleniumTestCase, SeleniumMixin, CircleSeleniumMixin):
"The view mode does not change for NODE listing"
)
"The view mode does not change for NODE listing"
)
def
test_11_delete_vm
(
self
):
def
test_11_delete_vm
(
self
):
logger
.
warning
(
"Starting test
%
s"
%
_getframe
()
.
f_code
.
co_name
)
self
.
login
()
self
.
login
()
succes
=
True
succes
=
True
for
vm
in
self
.
vm_ids
:
for
vm
in
self
.
vm_ids
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment