summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-10-27 23:30:55 -0600
committerJason Gerard DeRose <jderose@redhat.com>2008-10-27 23:30:55 -0600
commit6e456cc7494bc00e905361f3e6d42dff99089c6b (patch)
treef5987968fbd549ac4cf9a9fa4a16fe6384a70486 /tests
parent9b1e3f59465c6ba33f4266bc3add469b5e1711eb (diff)
downloadfreeipa-6e456cc7494bc00e905361f3e6d42dff99089c6b.tar.gz
freeipa-6e456cc7494bc00e905361f3e6d42dff99089c6b.tar.xz
freeipa-6e456cc7494bc00e905361f3e6d42dff99089c6b.zip
More CLI cleanup, got all basics working again
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ipalib/test_cli.py141
1 files changed, 77 insertions, 64 deletions
diff --git a/tests/test_ipalib/test_cli.py b/tests/test_ipalib/test_cli.py
index 7bcbfb0c6..c4740875b 100644
--- a/tests/test_ipalib/test_cli.py
+++ b/tests/test_ipalib/test_cli.py
@@ -110,6 +110,7 @@ class test_CLI(ClassChecker):
frontend.Application,
backend.Backend,
)
+ api.env.mode = 'unit-test'
api.env.in_tree = True
o = self.cls(api, argv)
assert o.api is api
@@ -135,57 +136,65 @@ class test_CLI(ClassChecker):
assert o.api is api
assert o.argv == tuple(argv)
- def test_parse_globals(self):
+ def test_run(self):
"""
- Test the `ipalib.cli.CLI.parse_globals` method.
+ Test the `ipalib.cli.CLI.run` method.
"""
- # Test with empty argv
+ self.check_cascade(
+ 'run',
+ 'finalize',
+ 'load_plugins',
+ 'bootstrap',
+ 'parse_globals'
+ )
+
+ def test_finalize(self):
+ """
+ Test the `ipalib.cli.CLI.finalize` method.
+ """
+ self.check_cascade(
+ 'finalize',
+ 'load_plugins',
+ 'bootstrap',
+ 'parse_globals'
+ )
+
(o, api, home) = self.new()
- assert not hasattr(o, 'options')
- assert not hasattr(o, 'cmd_argv')
- assert o.isdone('parse_globals') is False
- o.parse_globals()
- assert o.isdone('parse_globals') is True
- assert o.options.interactive is True
- assert o.options.verbose is False
- assert o.options.config_file is None
- assert o.options.environment is None
- assert o.cmd_argv == tuple()
- e = raises(StandardError, o.parse_globals)
- assert str(e) == 'CLI.parse_globals() already called'
+ assert api.isdone('finalize') is False
+ assert 'Command' not in api
+ o.finalize()
+ assert api.isdone('finalize') is True
+ assert list(api.Command) == \
+ sorted(k.__name__ for k in cli.cli_application_commands)
- # Test with a populated argv
- argv = ('-a', '-n', '-v', '-c', '/my/config.conf', '-e', 'my_key=my_val')
- cmd_argv = ('user-add', '--first', 'John', '--last', 'Doe')
- (o, api, home) = self.new(argv + cmd_argv)
- assert not hasattr(o, 'options')
- assert not hasattr(o, 'cmd_argv')
- assert o.isdone('parse_globals') is False
- o.parse_globals()
- assert o.isdone('parse_globals') is True
- assert o.options.prompt_all is True
- assert o.options.interactive is False
- assert o.options.verbose is True
- assert o.options.config_file == '/my/config.conf'
- assert o.options.environment == 'my_key=my_val'
- assert o.cmd_argv == cmd_argv
- e = raises(StandardError, o.parse_globals)
- assert str(e) == 'CLI.parse_globals() already called'
+ def test_load_plugins(self):
+ """
+ Test the `ipalib.cli.CLI.load_plugins` method.
+ """
+ self.check_cascade(
+ 'load_plugins',
+ 'bootstrap',
+ 'parse_globals'
+ )
+ (o, api, home) = self.new()
+ assert api.isdone('load_plugins') is False
+ o.load_plugins()
+ assert api.isdone('load_plugins') is True
def test_bootstrap(self):
"""
Test the `ipalib.cli.CLI.bootstrap` method.
"""
+ self.check_cascade(
+ 'bootstrap',
+ 'parse_globals'
+ )
# Test with empty argv
(o, api, home) = self.new()
keys = tuple(api.env)
assert api.isdone('bootstrap') is False
- assert o.isdone('parse_globals') is False
- assert o.isdone('bootstrap') is False
o.bootstrap()
assert api.isdone('bootstrap') is True
- assert o.isdone('parse_globals') is True
- assert o.isdone('bootstrap') is True
e = raises(StandardError, o.bootstrap)
assert str(e) == 'CLI.bootstrap() already called'
assert api.env.verbose is False
@@ -213,35 +222,39 @@ class test_CLI(ClassChecker):
assert api.env.from_cli_conf == 'set in cli.conf'
assert list(api.env) == sorted(keys + added)
- def test_load_plugins(self):
+ def test_parse_globals(self):
"""
- Test the `ipalib.cli.CLI.load_plugins` method.
+ Test the `ipalib.cli.CLI.parse_globals` method.
"""
- self.check_cascade(
- 'load_plugins',
- 'bootstrap',
- 'parse_globals'
- )
+ # Test with empty argv
(o, api, home) = self.new()
- assert api.isdone('load_plugins') is False
- o.load_plugins()
- assert api.isdone('load_plugins') is True
-
- def test_finalize(self):
- """
- Test the `ipalib.cli.CLI.finalize` method.
- """
- self.check_cascade(
- 'finalize',
- 'load_plugins',
- 'bootstrap',
- 'parse_globals'
- )
+ assert not hasattr(o, 'options')
+ assert not hasattr(o, 'cmd_argv')
+ assert o.isdone('parse_globals') is False
+ o.parse_globals()
+ assert o.isdone('parse_globals') is True
+ assert o.options.interactive is True
+ assert o.options.verbose is False
+ assert o.options.config_file is None
+ assert o.options.environment is None
+ assert o.cmd_argv == tuple()
+ e = raises(StandardError, o.parse_globals)
+ assert str(e) == 'CLI.parse_globals() already called'
- (o, api, home) = self.new()
- assert api.isdone('finalize') is False
- assert 'Command' not in api
- o.finalize()
- assert api.isdone('finalize') is True
- assert list(api.Command) == \
- sorted(k.__name__ for k in cli.cli_application_commands)
+ # Test with a populated argv
+ argv = ('-a', '-n', '-v', '-c', '/my/config.conf', '-e', 'my_key=my_val')
+ cmd_argv = ('user-add', '--first', 'John', '--last', 'Doe')
+ (o, api, home) = self.new(argv + cmd_argv)
+ assert not hasattr(o, 'options')
+ assert not hasattr(o, 'cmd_argv')
+ assert o.isdone('parse_globals') is False
+ o.parse_globals()
+ assert o.isdone('parse_globals') is True
+ assert o.options.prompt_all is True
+ assert o.options.interactive is False
+ assert o.options.verbose is True
+ assert o.options.config_file == '/my/config.conf'
+ assert o.options.environment == 'my_key=my_val'
+ assert o.cmd_argv == cmd_argv
+ e = raises(StandardError, o.parse_globals)
+ assert str(e) == 'CLI.parse_globals() already called'