Revision 1bd4f765
b/kamaki/cli/argument/__init__.py | ||
---|---|---|
144 | 144 |
_config_arg = ConfigArgument('Path to config file') |
145 | 145 |
|
146 | 146 |
|
147 |
class CmdLineConfigArgument(Argument):
|
|
147 |
class RuntimeConfigArgument(Argument):
|
|
148 | 148 |
"""Set a run-time setting option (not persistent)""" |
149 | 149 |
|
150 | 150 |
def __init__(self, config_arg, help='', parsed_name=None, default=None): |
... | ... | |
384 | 384 |
silent=FlagArgument('Do not output anything', ('-s', '--silent')), |
385 | 385 |
verbose=FlagArgument('More info at response', ('-v', '--verbose')), |
386 | 386 |
version=VersionArgument('Print current version', ('-V', '--version')), |
387 |
options=CmdLineConfigArgument(
|
|
387 |
options=RuntimeConfigArgument(
|
|
388 | 388 |
_config_arg, 'Override a config value', ('-o', '--options')) |
389 | 389 |
) |
390 | 390 |
|
b/kamaki/cli/argument/test.py | ||
---|---|---|
34 | 34 |
from mock import patch, call |
35 | 35 |
from unittest import TestCase |
36 | 36 |
from StringIO import StringIO |
37 |
#from itertools import product
|
|
37 |
from itertools import product |
|
38 | 38 |
|
39 | 39 |
from kamaki.cli import argument |
40 | 40 |
from kamaki.cli.config import Config |
... | ... | |
161 | 161 |
self.assertRaises(KeyError, c.get_cloud, invalidcloud, 'url') |
162 | 162 |
|
163 | 163 |
|
164 |
class RuntimeConfigArgument(TestCase): |
|
165 |
|
|
166 |
def setUp(self): |
|
167 |
argument._config_arg = argument.ConfigArgument('Recovered Path') |
|
168 |
|
|
169 |
@patch('kamaki.cli.argument.Argument.__init__') |
|
170 |
def test___init__(self, arg): |
|
171 |
config, help, pname, default = 'config', 'help', 'pname', 'default' |
|
172 |
rca = argument.RuntimeConfigArgument(config, help, pname, default) |
|
173 |
self.assertTrue(isinstance(rca, argument.RuntimeConfigArgument)) |
|
174 |
self.assertEqual(rca._config_arg, config) |
|
175 |
self.assertEqual(arg.mock_calls[-1], call(1, help, pname, default)) |
|
176 |
|
|
177 |
|
|
164 | 178 |
if __name__ == '__main__': |
165 | 179 |
from sys import argv |
166 | 180 |
from kamaki.cli.test import runTestCase |
167 | 181 |
runTestCase(Argument, 'Argument', argv[1:]) |
168 | 182 |
runTestCase(ConfigArgument, 'ConfigArgument', argv[1:]) |
183 |
runTestCase(RuntimeConfigArgument, 'RuntimeConfigArgument', argv[1:]) |
b/kamaki/cli/test.py | ||
---|---|---|
36 | 36 |
|
37 | 37 |
from kamaki.cli.command_tree.test import Command, CommandTree |
38 | 38 |
from kamaki.cli.argument.test import Argument, ConfigArgument |
39 |
from kamaki.cli.argument.test import RuntimeConfigArgument |
|
39 | 40 |
|
40 | 41 |
|
41 | 42 |
# TestCase auxiliary methods |
Also available in: Unified diff