Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7ffc1a87
authored
Jul 04, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix tests
parent
a7259472
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
circle/dashboard/fixtures/test-vm-fixture.json
+18
-0
circle/dashboard/tests/test_mockedviews.py
+6
-4
circle/dashboard/tests/test_views.py
+6
-0
No files found.
circle/dashboard/fixtures/test-vm-fixture.json
View file @
7ffc1a87
...
...
@@ -1240,6 +1240,24 @@
}
},
{
"pk"
:
1367
,
"model"
:
"auth.permission"
,
"fields"
:
{
"codename"
:
"create_vm"
,
"name"
:
"Can create a new VM."
,
"content_type"
:
28
}
},
{
"pk"
:
1368
,
"model"
:
"auth.permission"
,
"fields"
:
{
"codename"
:
"access_console"
,
"name"
:
"Can access the graphical console of a VM."
,
"content_type"
:
28
}
},
{
"pk"
:
1
,
"model"
:
"auth.group"
,
"fields"
:
{
...
...
circle/dashboard/tests/test_mockedviews.py
View file @
7ffc1a87
...
...
@@ -159,7 +159,7 @@ class VmOperationViewTestCase(unittest.TestCase):
assert
not
msg
.
error
.
called
def
test_migrate_failed
(
self
):
request
=
FakeRequestFactory
(
POST
=
{
'node'
:
1
})
request
=
FakeRequestFactory
(
POST
=
{
'node'
:
1
}
,
superuser
=
True
)
view
=
vm_ops
[
'migrate'
]
with
patch
.
object
(
view
,
'get_object'
)
as
go
,
\
...
...
@@ -177,7 +177,7 @@ class VmOperationViewTestCase(unittest.TestCase):
assert
msg
.
error
.
called
def
test_migrate_template
(
self
):
request
=
FakeRequestFactory
()
request
=
FakeRequestFactory
(
superuser
=
True
)
view
=
vm_ops
[
'migrate'
]
with
patch
.
object
(
view
,
'get_object'
)
as
go
:
...
...
@@ -190,7 +190,7 @@ class VmOperationViewTestCase(unittest.TestCase):
view
.
as_view
()(
request
,
pk
=
1234
)
.
render
()
.
status_code
,
200
)
def
test_save_as_wo_name
(
self
):
request
=
FakeRequestFactory
(
POST
=
{})
request
=
FakeRequestFactory
(
POST
=
{}
,
has_perms_mock
=
True
)
view
=
vm_ops
[
'save_as_template'
]
with
patch
.
object
(
view
,
'get_object'
)
as
go
,
\
...
...
@@ -224,7 +224,7 @@ class VmOperationViewTestCase(unittest.TestCase):
assert
not
msg
.
error
.
called
def
test_save_as_template
(
self
):
request
=
FakeRequestFactory
()
request
=
FakeRequestFactory
(
has_perms_mock
=
True
)
view
=
vm_ops
[
'save_as_template'
]
with
patch
.
object
(
view
,
'get_object'
)
as
go
:
...
...
@@ -246,6 +246,8 @@ def FakeRequestFactory(*args, **kwargs):
user
=
UserFactory
()
user
.
is_authenticated
=
lambda
:
kwargs
.
get
(
'authenticated'
,
True
)
user
.
is_superuser
=
kwargs
.
get
(
'superuser'
,
False
)
if
kwargs
.
get
(
'has_perms_mock'
,
False
):
user
.
has_perms
=
MagicMock
(
return_value
=
True
)
request
=
HttpRequest
()
request
.
user
=
user
...
...
circle/dashboard/tests/test_views.py
View file @
7ffc1a87
...
...
@@ -63,6 +63,8 @@ class VmDetailTest(LoginMixin, TestCase):
self
.
g1
.
user_set
.
add
(
self
.
u1
)
self
.
g1
.
user_set
.
add
(
self
.
u2
)
self
.
g1
.
save
()
self
.
u1
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'create_vm'
))
settings
[
"default_vlangroup"
]
=
'public'
VlanGroup
.
objects
.
create
(
name
=
'public'
)
...
...
@@ -1544,6 +1546,8 @@ class VmDetailVncTest(LoginMixin, TestCase):
inst
.
node
=
Node
.
objects
.
all
()[
0
]
inst
.
save
()
inst
.
set_level
(
self
.
u1
,
'operator'
)
self
.
u1
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'access_console'
))
response
=
c
.
get
(
'/dashboard/vm/1/vnctoken/'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -1554,6 +1558,8 @@ class VmDetailVncTest(LoginMixin, TestCase):
inst
.
node
=
Node
.
objects
.
all
()[
0
]
inst
.
save
()
inst
.
set_level
(
self
.
u1
,
'user'
)
self
.
u1
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'access_console'
))
response
=
c
.
get
(
'/dashboard/vm/1/vnctoken/'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
...
...
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