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
ff7dcb4f
authored
Apr 28, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: tests for operations
parent
d83db63b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
circle/common/operations.py
+1
-2
circle/common/tests/test_operations.py
+38
-0
No files found.
circle/common/operations.py
View file @
ff7dcb4f
...
...
@@ -44,8 +44,7 @@ class Operation(object):
# check for unexpected keyword arguments
argspec
=
getargspec
(
self
.
_operation
)
if
argspec
.
keywords
is
None
:
# _operation doesn't take ** args
unexpected_kwargs
=
set
(
arg
for
arg
in
auxargs
if
arg
not
in
argspec
.
args
)
unexpected_kwargs
=
set
(
auxargs
)
-
set
(
argspec
.
args
)
if
unexpected_kwargs
:
raise
TypeError
(
"Operation got unexpected keyword arguments: "
"
%
s"
%
", "
.
join
(
unexpected_kwargs
))
...
...
circle/common/tests/test_operations.py
View file @
ff7dcb4f
...
...
@@ -58,3 +58,41 @@ class OperationTestCase(TestCase):
patch
.
object
(
Operation
,
'create_activity'
),
\
patch
.
object
(
Operation
,
'_exec_op'
):
op
.
call
(
system
=
True
)
def
test_no_exception_for_more_arguments_when_operation_takes_kwargs
(
self
):
class
KwargOp
(
Operation
):
activity_code_suffix
=
'test'
id
=
'test'
def
_operation
(
self
,
**
kwargs
):
pass
op
=
KwargOp
(
MagicMock
())
with
patch
.
object
(
KwargOp
,
'create_activity'
),
\
patch
.
object
(
KwargOp
,
'_exec_op'
):
op
.
call
(
system
=
True
,
foo
=
42
)
def
test_exception_for_unexpected_arguments
(
self
):
class
TestOp
(
Operation
):
activity_code_suffix
=
'test'
id
=
'test'
def
_operation
(
self
):
pass
op
=
TestOp
(
MagicMock
())
with
patch
.
object
(
TestOp
,
'create_activity'
),
\
patch
.
object
(
TestOp
,
'_exec_op'
):
self
.
assertRaises
(
TypeError
,
op
.
call
,
system
=
True
,
foo
=
42
)
def
test_exception_for_missing_arguments
(
self
):
class
TestOp
(
Operation
):
activity_code_suffix
=
'test'
id
=
'test'
def
_operation
(
self
,
foo
):
pass
op
=
TestOp
(
MagicMock
())
with
patch
.
object
(
TestOp
,
'create_activity'
):
self
.
assertRaises
(
TypeError
,
op
.
call
,
system
=
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