Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
7156a8be
authored
Jul 29, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: fix tests
parent
682973b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
circle/dashboard/tests/test_views.py
+21
-19
No files found.
circle/dashboard/tests/test_views.py
View file @
7156a8be
...
@@ -529,36 +529,38 @@ class VmDetailTest(LoginMixin, TestCase):
...
@@ -529,36 +529,38 @@ class VmDetailTest(LoginMixin, TestCase):
def
test_permitted_wake_up_wrong_state
(
self
):
def
test_permitted_wake_up_wrong_state
(
self
):
c
=
Client
()
c
=
Client
()
self
.
login
(
c
,
"user2"
)
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
WakeUpOperation
,
'async'
)
as
mock_method
:
with
patch
.
object
(
WakeUpOperation
,
'async'
)
as
mock_method
,
\
patch
.
object
(
Instance
.
WrongStateError
,
'send_message'
)
as
wro
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
mock_method
.
side_effect
=
inst
.
wake_up
mock_method
.
side_effect
=
inst
.
wake_up
inst
.
status
=
'RUNNING'
inst
.
status
=
'RUNNING'
inst
.
set_level
(
self
.
u2
,
'owner'
)
inst
.
set_level
(
self
.
u2
,
'owner'
)
with
patch
(
'dashboard.views.messages'
)
as
msg
:
c
.
post
(
"/dashboard/vm/1/op/wake_up/"
)
c
.
post
(
"/dashboard/vm/1/op/wake_up/"
)
assert
msg
.
error
.
called
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
# mocked anyway
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
# mocked anyway
assert
mock_method
.
called
assert
mock_method
.
called
assert
wro
.
called
def
test_permitted_wake_up
(
self
):
def
test_permitted_wake_up
(
self
):
c
=
Client
()
c
=
Client
()
self
.
login
(
c
,
"user2"
)
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
Instance
,
'select_node'
,
return_value
=
None
):
with
patch
.
object
(
Instance
,
'select_node'
,
return_value
=
None
),
\
with
patch
.
object
(
WakeUpOperation
,
'async'
)
as
new_wake_up
:
patch
.
object
(
WakeUpOperation
,
'async'
)
as
new_wake_up
,
\
with
patch
(
'vm.tasks.vm_tasks.wake_up.apply_async'
)
as
wuaa
:
patch
(
'vm.tasks.vm_tasks.wake_up.apply_async'
)
as
wuaa
,
\
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
patch
.
object
(
Instance
.
WrongStateError
,
'send_message'
)
as
wro
:
new_wake_up
.
side_effect
=
inst
.
wake_up
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
new_wake_up
.
side_effect
=
inst
.
wake_up
inst
.
status
=
'SUSPENDED'
inst
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
inst
.
set_level
(
self
.
u2
,
'owner'
)
inst
.
status
=
'SUSPENDED'
with
patch
(
'dashboard.views.messages'
)
as
msg
:
inst
.
set_level
(
self
.
u2
,
'owner'
)
response
=
c
.
post
(
"/dashboard/vm/1/op/wake_up/"
)
with
patch
(
'dashboard.views.messages'
)
as
msg
:
assert
not
msg
.
error
.
called
response
=
c
.
post
(
"/dashboard/vm/1/op/wake_up/"
)
self
.
assertEqual
(
response
.
status_code
,
302
)
assert
not
msg
.
error
.
called
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
assert
new_wake_up
.
called
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
assert
wuaa
.
called
assert
new_wake_up
.
called
assert
wuaa
.
called
assert
not
wro
.
called
def
test_unpermitted_wake_up
(
self
):
def
test_unpermitted_wake_up
(
self
):
c
=
Client
()
c
=
Client
()
...
...
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