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
429b89bb
authored
Apr 22, 2016
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add lease detail tests
parent
bc0bd870
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
27 deletions
+73
-27
circle/dashboard/tests/test_views.py
+73
-27
No files found.
circle/dashboard/tests/test_views.py
View file @
429b89bb
...
@@ -270,33 +270,6 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
...
@@ -270,33 +270,6 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
self
.
assertEqual
(
InstanceTemplate
.
objects
.
get
(
id
=
1
)
.
raw_data
,
self
.
assertEqual
(
InstanceTemplate
.
objects
.
get
(
id
=
1
)
.
raw_data
,
"<devices></devices>"
)
"<devices></devices>"
)
def
test_permitted_lease_delete_w_template_using_it
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
leases
=
Lease
.
objects
.
count
()
response
=
c
.
post
(
"/dashboard/lease/delete/1/"
)
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
leases
,
Lease
.
objects
.
count
())
def
test_permitted_lease_delete_w_template_not_using_it
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
lease
=
Lease
.
objects
.
create
(
name
=
"yay"
)
leases
=
Lease
.
objects
.
count
()
response
=
c
.
post
(
"/dashboard/lease/delete/
%
d/"
%
lease
.
pk
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
leases
-
1
,
Lease
.
objects
.
count
())
def
test_unpermitted_lease_delete
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
leases
=
Lease
.
objects
.
count
()
response
=
c
.
post
(
"/dashboard/lease/delete/1/"
)
# redirect to the login page
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
leases
,
Lease
.
objects
.
count
())
def
test_notification_read
(
self
):
def
test_notification_read
(
self
):
c
=
Client
()
c
=
Client
()
self
.
login
(
c
,
"user1"
)
self
.
login
(
c
,
"user1"
)
...
@@ -1758,3 +1731,76 @@ class SshKeyTest(LoginMixin, TestCase):
...
@@ -1758,3 +1731,76 @@ class SshKeyTest(LoginMixin, TestCase):
resp
=
c
.
post
(
"/dashboard/sshkey/delete/1/"
)
resp
=
c
.
post
(
"/dashboard/sshkey/delete/1/"
)
self
.
assertEqual
(
403
,
resp
.
status_code
)
self
.
assertEqual
(
403
,
resp
.
status_code
)
class
LeaseDetailTest
(
LoginMixin
,
TestCase
):
fixtures
=
[
'test-vm-fixture.json'
,
]
def
setUp
(
self
):
self
.
u1
=
User
.
objects
.
create
(
username
=
'user1'
)
self
.
u1
.
set_password
(
'password'
)
self
.
u1
.
save
()
self
.
u2
=
User
.
objects
.
create
(
username
=
'user2'
,
is_staff
=
True
)
self
.
u2
.
set_password
(
'password'
)
self
.
u2
.
save
()
self
.
us
=
User
.
objects
.
create
(
username
=
'superuser'
,
is_superuser
=
True
)
self
.
us
.
set_password
(
'password'
)
self
.
us
.
save
()
def
tearDown
(
self
):
super
(
LeaseDetailTest
,
self
)
.
tearDown
()
self
.
u1
.
delete
()
self
.
u2
.
delete
()
self
.
us
.
delete
()
def
test_anon_view
(
self
):
c
=
Client
()
response
=
c
.
get
(
"/dashboard/lease/1/"
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_unpermitted_view
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
response
=
c
.
get
(
"/dashboard/lease/1/"
)
self
.
assertEqual
(
response
.
status_code
,
302
)
def
test_operator_view
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user2'
)
lease
=
Lease
.
objects
.
get
()
lease
.
set_level
(
self
.
u2
,
"owner"
)
response
=
c
.
get
(
"/dashboard/lease/1/"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_superuser_view
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
response
=
c
.
get
(
"/dashboard/lease/1/"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_permitted_lease_delete_w_template_using_it
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
leases
=
Lease
.
objects
.
count
()
response
=
c
.
post
(
"/dashboard/lease/delete/1/"
)
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
leases
,
Lease
.
objects
.
count
())
def
test_permitted_lease_delete_w_template_not_using_it
(
self
):
c
=
Client
()
self
.
login
(
c
,
'superuser'
)
lease
=
Lease
.
objects
.
create
(
name
=
"yay"
)
leases
=
Lease
.
objects
.
count
()
response
=
c
.
post
(
"/dashboard/lease/delete/
%
d/"
%
lease
.
pk
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
leases
-
1
,
Lease
.
objects
.
count
())
def
test_unpermitted_lease_delete
(
self
):
c
=
Client
()
self
.
login
(
c
,
'user1'
)
leases
=
Lease
.
objects
.
count
()
response
=
c
.
post
(
"/dashboard/lease/delete/1/"
)
# redirect to the login page
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
leases
,
Lease
.
objects
.
count
())
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