Commit 1bd4f765 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Initialize RuntimeConfigArgument unittests

Refs: #4058
parent c89d5f34
......@@ -144,7 +144,7 @@ class ConfigArgument(Argument):
_config_arg = ConfigArgument('Path to config file')
class CmdLineConfigArgument(Argument):
class RuntimeConfigArgument(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=CmdLineConfigArgument(
options=RuntimeConfigArgument(
_config_arg, 'Override a config value', ('-o', '--options'))
)
......
......@@ -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:])
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment