diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-10-27 16:08:17 -0600 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-10-27 16:08:17 -0600 |
commit | 491e295412fceead7cf0c6c9cdd44904541e4044 (patch) | |
tree | dbcede7cc4025a4ccb4a3a31f3a4063672590c95 /tests | |
parent | bb9691099b7b025fc491279314d8803f4fa3b571 (diff) | |
download | freeipa-491e295412fceead7cf0c6c9cdd44904541e4044.tar.gz freeipa-491e295412fceead7cf0c6c9cdd44904541e4044.tar.xz freeipa-491e295412fceead7cf0c6c9cdd44904541e4044.zip |
Unit test for CLI.boostrap() now checks that -e overrides and values from config files are merged in correctly
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_ipalib/test_cli.py | 41 | ||||
-rw-r--r-- | tests/test_ipalib/test_plugable.py | 3 |
2 files changed, 43 insertions, 1 deletions
diff --git a/tests/test_ipalib/test_cli.py b/tests/test_ipalib/test_cli.py index 39959270..389bb52c 100644 --- a/tests/test_ipalib/test_cli.py +++ b/tests/test_ipalib/test_cli.py @@ -76,6 +76,24 @@ class DummyAPI(object): pass +config_cli = """ +[global] + +from_cli_conf = set in cli.conf +""" + +config_default = """ +[global] + +from_default_conf = set in default.conf + +# Make sure cli.conf is loaded first: +from_cli_conf = overridden in default.conf +""" + + + + class test_CLI(ClassChecker): """ Test the `ipalib.cli.CLI` class. @@ -147,6 +165,7 @@ class test_CLI(ClassChecker): """ Test the `ipalib.cli.CLI.bootstrap` method. """ + # Test with empty argv (o, api, home) = self.new() keys = tuple(api.env) assert api.isdone('bootstrap') is False @@ -160,3 +179,25 @@ class test_CLI(ClassChecker): assert str(e) == 'CLI.bootstrap() already called' assert api.env.verbose is False assert api.env.context == 'cli' + keys = tuple(api.env) + added = ( + 'my_key', + 'whatever', + 'from_default_conf', + 'from_cli_conf' + ) + for key in added: + assert key not in api.env + assert key not in keys + + # Test with a populated argv + argv = ['-e', 'my_key=my_val,whatever=Hello'] + (o, api, home) = self.new(argv) + home.write(config_default, '.ipa', 'default.conf') + home.write(config_cli, '.ipa', 'cli.conf') + o.bootstrap() + assert api.env.my_key == 'my_val' + assert api.env.whatever == 'Hello' + assert api.env.from_default_conf == 'set in default.conf' + assert api.env.from_cli_conf == 'set in cli.conf' + assert list(api.env) == sorted(keys + added) diff --git a/tests/test_ipalib/test_plugable.py b/tests/test_ipalib/test_plugable.py index 50cab930..85b5303c 100644 --- a/tests/test_ipalib/test_plugable.py +++ b/tests/test_ipalib/test_plugable.py @@ -887,10 +887,11 @@ class test_API(ClassChecker): assert o.env._isdone('_bootstrap') is False assert o.env._isdone('_finalize_core') is False assert o.isdone('bootstrap') is False - o.bootstrap() + o.bootstrap(my_test_override='Hello, world!') assert o.isdone('bootstrap') is True assert o.env._isdone('_bootstrap') is True assert o.env._isdone('_finalize_core') is True + assert o.env.my_test_override == 'Hello, world!' e = raises(StandardError, o.bootstrap) assert str(e) == 'API.bootstrap() already called' |