Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
1bd4f765
Commit
1bd4f765
authored
Jul 17, 2013
by
Stavros Sachtouris
Browse files
Initialize RuntimeConfigArgument unittests
Refs: #4058
parent
c89d5f34
Changes
3
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/argument/__init__.py
View file @
1bd4f765
...
...
@@ -144,7 +144,7 @@ class ConfigArgument(Argument):
_config_arg
=
ConfigArgument
(
'Path to config file'
)
class
CmdLin
eConfigArgument
(
Argument
):
class
Runtim
eConfigArgument
(
Argument
):
"""Set a run-time setting option (not persistent)"""
def
__init__
(
self
,
config_arg
,
help
=
''
,
parsed_name
=
None
,
default
=
None
):
...
...
@@ -384,7 +384,7 @@ _arguments = dict(
silent
=
FlagArgument
(
'Do not output anything'
,
(
'-s'
,
'--silent'
)),
verbose
=
FlagArgument
(
'More info at response'
,
(
'-v'
,
'--verbose'
)),
version
=
VersionArgument
(
'Print current version'
,
(
'-V'
,
'--version'
)),
options
=
CmdLin
eConfigArgument
(
options
=
Runtim
eConfigArgument
(
_config_arg
,
'Override a config value'
,
(
'-o'
,
'--options'
))
)
...
...
kamaki/cli/argument/test.py
View file @
1bd4f765
...
...
@@ -34,7 +34,7 @@
from
mock
import
patch
,
call
from
unittest
import
TestCase
from
StringIO
import
StringIO
#
from itertools import product
from
itertools
import
product
from
kamaki.cli
import
argument
from
kamaki.cli.config
import
Config
...
...
@@ -161,8 +161,23 @@ class ConfigArgument(TestCase):
self
.
assertRaises
(
KeyError
,
c
.
get_cloud
,
invalidcloud
,
'url'
)
class
RuntimeConfigArgument
(
TestCase
):
def
setUp
(
self
):
argument
.
_config_arg
=
argument
.
ConfigArgument
(
'Recovered Path'
)
@
patch
(
'kamaki.cli.argument.Argument.__init__'
)
def
test___init__
(
self
,
arg
):
config
,
help
,
pname
,
default
=
'config'
,
'help'
,
'pname'
,
'default'
rca
=
argument
.
RuntimeConfigArgument
(
config
,
help
,
pname
,
default
)
self
.
assertTrue
(
isinstance
(
rca
,
argument
.
RuntimeConfigArgument
))
self
.
assertEqual
(
rca
.
_config_arg
,
config
)
self
.
assertEqual
(
arg
.
mock_calls
[
-
1
],
call
(
1
,
help
,
pname
,
default
))
if
__name__
==
'__main__'
:
from
sys
import
argv
from
kamaki.cli.test
import
runTestCase
runTestCase
(
Argument
,
'Argument'
,
argv
[
1
:])
runTestCase
(
ConfigArgument
,
'ConfigArgument'
,
argv
[
1
:])
runTestCase
(
RuntimeConfigArgument
,
'RuntimeConfigArgument'
,
argv
[
1
:])
kamaki/cli/test.py
View file @
1bd4f765
...
...
@@ -36,6 +36,7 @@ from inspect import getmembers, isclass
from
kamaki.cli.command_tree.test
import
Command
,
CommandTree
from
kamaki.cli.argument.test
import
Argument
,
ConfigArgument
from
kamaki.cli.argument.test
import
RuntimeConfigArgument
# TestCase auxiliary methods
...
...
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