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
407db0d3
authored
Apr 04, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix tests
parent
e5a442ad
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
20 deletions
+15
-20
circle/vm/tests/test_models.py
+15
-20
No files found.
circle/vm/tests/test_models.py
View file @
407db0d3
...
@@ -175,25 +175,19 @@ class InstanceActivityTestCase(TestCase):
...
@@ -175,25 +175,19 @@ class InstanceActivityTestCase(TestCase):
instance
.
activity_log
.
filter
.
return_value
.
exists
.
return_value
=
True
instance
.
activity_log
.
filter
.
return_value
.
exists
.
return_value
=
True
with
self
.
assertRaises
(
ActivityInProgressError
):
with
self
.
assertRaises
(
ActivityInProgressError
):
InstanceActivity
.
create
(
"test"
,
instance
,
concurrency_check
=
True
)
InstanceActivity
.
create
(
'test'
,
instance
,
concurrency_check
=
True
)
def
test_create_no_concurrency_check
(
self
):
def
test_create_no_concurrency_check
(
self
):
instance
=
MagicMock
(
spec
=
Instance
)
instance
=
MagicMock
(
spec
=
Instance
)
instance
.
activity_log
.
filter
.
return_value
.
exists
.
return_value
=
True
instance
.
activity_log
.
filter
.
return_value
.
exists
.
return_value
=
True
original_method
=
InstanceActivity
.
create
.
__func__
with
patch
.
object
(
InstanceActivity
,
'__new__'
):
try
:
with
patch
(
'vm.models.activity.InstanceActivity'
)
as
ia
,
\
InstanceActivity
.
create
(
'test'
,
instance
,
patch
(
'vm.models.activity.timezone.now'
):
concurrency_check
=
False
)
# ia.__init__ = MagicMock() raises AttributeError
except
ActivityInProgressError
:
raise
AssertionError
(
"'create' method checked for concurrent "
original_method
(
ia
,
"test"
,
instance
,
concurrency_check
=
False
)
"activities."
)
ia
.
save
.
assert_called
()
# ia.__init__.assert_called_with(activity_code='vm.Instance.test',
# instance=instance, parent=None,
# resultant_state=None, started=now,
# task_uuid=None, user=None)
def
test_create_sub_concurrency_check
(
self
):
def
test_create_sub_concurrency_check
(
self
):
iaobj
=
MagicMock
(
spec
=
InstanceActivity
)
iaobj
=
MagicMock
(
spec
=
InstanceActivity
)
...
@@ -207,12 +201,13 @@ class InstanceActivityTestCase(TestCase):
...
@@ -207,12 +201,13 @@ class InstanceActivityTestCase(TestCase):
iaobj
.
activity_code
=
'test'
iaobj
.
activity_code
=
'test'
iaobj
.
children
.
filter
.
return_value
.
exists
.
return_value
=
True
iaobj
.
children
.
filter
.
return_value
.
exists
.
return_value
=
True
original_method
=
InstanceActivity
.
create_sub
with
patch
.
object
(
InstanceActivity
,
'__new__'
):
try
:
with
patch
(
'vm.models.activity.InstanceActivity'
)
as
ia
,
\
InstanceActivity
.
create_sub
(
iaobj
,
'test'
,
patch
(
'vm.models.activity.timezone.now'
):
concurrency_check
=
False
)
original_method
(
iaobj
,
"test"
,
concurrency_check
=
False
)
except
ActivityInProgressError
:
ia
.
save
.
assert_called
()
raise
AssertionError
(
"'create_sub' method checked for "
"concurrent activities."
)
def
test_disable_enabled
(
self
):
def
test_disable_enabled
(
self
):
node
=
MagicMock
(
spec
=
Node
,
enabled
=
True
)
node
=
MagicMock
(
spec
=
Node
,
enabled
=
True
)
...
...
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