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
Commit
a89d41d2
authored
Oct 01, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix tests
parent
b0e7d502
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
circle/vm/tests/test_models.py
+12
-8
No files found.
circle/vm/tests/test_models.py
View file @
a89d41d2
...
@@ -29,7 +29,8 @@ from ..models import (
...
@@ -29,7 +29,8 @@ from ..models import (
)
)
from
..models.instance
import
find_unused_port
,
ActivityInProgressError
from
..models.instance
import
find_unused_port
,
ActivityInProgressError
from
..operations
import
(
from
..operations
import
(
DeployOperation
,
DestroyOperation
,
FlushOperation
,
MigrateOperation
,
RemoteOperationMixin
,
DeployOperation
,
DestroyOperation
,
FlushOperation
,
MigrateOperation
,
)
)
...
@@ -105,7 +106,8 @@ class InstanceTestCase(TestCase):
...
@@ -105,7 +106,8 @@ class InstanceTestCase(TestCase):
inst
.
node
=
MagicMock
(
spec
=
Node
)
inst
.
node
=
MagicMock
(
spec
=
Node
)
inst
.
status
=
'RUNNING'
inst
.
status
=
'RUNNING'
migrate_op
=
MigrateOperation
(
inst
)
migrate_op
=
MigrateOperation
(
inst
)
with
patch
(
'vm.models.instance.vm_tasks.migrate'
)
as
migr
:
with
patch
(
'vm.operations.vm_tasks.migrate'
)
as
migr
,
\
patch
.
object
(
RemoteOperationMixin
,
"_operation"
):
act
=
MagicMock
()
act
=
MagicMock
()
with
patch
.
object
(
MigrateOperation
,
'create_activity'
,
with
patch
.
object
(
MigrateOperation
,
'create_activity'
,
return_value
=
act
):
return_value
=
act
):
...
@@ -122,7 +124,8 @@ class InstanceTestCase(TestCase):
...
@@ -122,7 +124,8 @@ class InstanceTestCase(TestCase):
inst
.
node
=
MagicMock
(
spec
=
Node
)
inst
.
node
=
MagicMock
(
spec
=
Node
)
inst
.
status
=
'RUNNING'
inst
.
status
=
'RUNNING'
migrate_op
=
MigrateOperation
(
inst
)
migrate_op
=
MigrateOperation
(
inst
)
with
patch
(
'vm.models.instance.vm_tasks.migrate'
)
as
migr
:
with
patch
(
'vm.operations.vm_tasks.migrate'
)
as
migr
,
\
patch
.
object
(
RemoteOperationMixin
,
"_operation"
):
inst
.
select_node
.
side_effect
=
AssertionError
inst
.
select_node
.
side_effect
=
AssertionError
act
=
MagicMock
()
act
=
MagicMock
()
with
patch
.
object
(
MigrateOperation
,
'create_activity'
,
with
patch
.
object
(
MigrateOperation
,
'create_activity'
,
...
@@ -139,20 +142,21 @@ class InstanceTestCase(TestCase):
...
@@ -139,20 +142,21 @@ class InstanceTestCase(TestCase):
inst
.
status
=
'RUNNING'
inst
.
status
=
'RUNNING'
e
=
Exception
(
'abc'
)
e
=
Exception
(
'abc'
)
setattr
(
e
,
'libvirtError'
,
''
)
setattr
(
e
,
'libvirtError'
,
''
)
inst
.
migrate_vm
.
side_effect
=
e
migrate_op
=
MigrateOperation
(
inst
)
migrate_op
=
MigrateOperation
(
inst
)
with
patch
(
'vm.models.instance.vm_tasks.migrate'
)
as
migr
:
migrate_op
.
rollback
=
Mock
()
with
patch
(
'vm.operations.vm_tasks.migrate'
)
as
migr
,
\
patch
.
object
(
RemoteOperationMixin
,
'_operation'
)
as
remop
:
act
=
MagicMock
()
act
=
MagicMock
()
remop
.
side_effect
=
e
with
patch
.
object
(
MigrateOperation
,
'create_activity'
,
with
patch
.
object
(
MigrateOperation
,
'create_activity'
,
return_value
=
act
):
return_value
=
act
):
self
.
assertRaises
(
Exception
,
migrate_op
,
system
=
True
)
self
.
assertRaises
(
Exception
,
migrate_op
,
system
=
True
)
remop
.
assert_called
()
migr
.
apply_async
.
assert_called
()
migr
.
apply_async
.
assert_called
()
self
.
assertIn
(
call
.
sub_activity
(
self
.
assertIn
(
call
.
sub_activity
(
u'scheduling'
,
readable_name
=
u'schedule'
),
act
.
mock_calls
)
u'scheduling'
,
readable_name
=
u'schedule'
),
act
.
mock_calls
)
self
.
assertIn
(
call
.
sub_activity
(
migrate_op
.
rollback
.
assert_called
()
u'rollback_net'
,
readable_name
=
u'redeploy network (rollback)'
),
act
.
mock_calls
)
inst
.
select_node
.
assert_called
()
inst
.
select_node
.
assert_called
()
def
test_status_icon
(
self
):
def
test_status_icon
(
self
):
...
...
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