diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-10-30 01:34:46 -0600 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-10-30 01:34:46 -0600 |
commit | 2fee6a3e20169f12b837647f0f71d6f28937490f (patch) | |
tree | f84fc2ad8486a70ba51be6cd36214ab9dc6ac53f /tests/test_ipalib | |
parent | ddb5449c7faabbd4c1b71adfe84c386b943a163f (diff) | |
download | freeipa-2fee6a3e20169f12b837647f0f71d6f28937490f.tar.gz freeipa-2fee6a3e20169f12b837647f0f71d6f28937490f.tar.xz freeipa-2fee6a3e20169f12b837647f0f71d6f28937490f.zip |
Added tests.util.get_api() function to create a standard (api, home) tuple for unit testing
Diffstat (limited to 'tests/test_ipalib')
-rw-r--r-- | tests/test_ipalib/test_cli.py | 17 | ||||
-rw-r--r-- | tests/test_ipalib/test_plugable.py | 15 |
2 files changed, 7 insertions, 25 deletions
diff --git a/tests/test_ipalib/test_cli.py b/tests/test_ipalib/test_cli.py index 7b3239d7c..f13db51eb 100644 --- a/tests/test_ipalib/test_cli.py +++ b/tests/test_ipalib/test_cli.py @@ -21,8 +21,7 @@ Test the `ipalib.cli` module. """ -from tests.util import raises, getitem, no_set, no_del, read_only, ClassChecker -from tests.util import TempHome +from tests.util import raises, get_api, ClassChecker from ipalib import cli, plugable, frontend, backend @@ -92,8 +91,6 @@ from_cli_conf = overridden in default.conf """ - - class test_CLI(ClassChecker): """ Test the `ipalib.cli.CLI` class. @@ -101,17 +98,7 @@ class test_CLI(ClassChecker): _cls = cli.CLI def new(self, argv=tuple()): - home = TempHome() - api = plugable.API( - frontend.Command, - frontend.Object, - frontend.Method, - frontend.Property, - frontend.Application, - backend.Backend, - ) - api.env.mode = 'unit_test' - api.env.in_tree = True + (api, home) = get_api() o = self.cls(api, argv) assert o.api is api return (o, api, home) diff --git a/tests/test_ipalib/test_plugable.py b/tests/test_ipalib/test_plugable.py index c7b8abbd9..ce0c79a97 100644 --- a/tests/test_ipalib/test_plugable.py +++ b/tests/test_ipalib/test_plugable.py @@ -23,7 +23,7 @@ Test the `ipalib.plugable` module. from tests.util import raises, no_set, no_del, read_only from tests.util import getitem, setitem, delitem -from tests.util import ClassChecker, TempHome +from tests.util import ClassChecker, get_api from ipalib import plugable, errors @@ -771,13 +771,6 @@ class test_API(ClassChecker): _cls = plugable.API - def new(self, *bases): - home = TempHome() - api = self.cls(*bases) - api.env.mode = 'unit_test' - api.env.in_tree = True - return (api, home) - def test_API(self): """ Test the `ipalib.plugable.API` class. @@ -802,6 +795,8 @@ class test_API(ClassChecker): return n + 1 api = plugable.API(base0, base1) + api.env.mode = 'unit_test' + api.env.in_tree = True r = api.register assert isinstance(r, plugable.Registrar) assert read_only(api, 'register') is r @@ -884,7 +879,7 @@ class test_API(ClassChecker): """ Test the `ipalib.plugable.API.bootstrap` method. """ - (o, home) = self.new() + (o, home) = get_api() assert o.env._isdone('_bootstrap') is False assert o.env._isdone('_finalize_core') is False assert o.isdone('bootstrap') is False @@ -900,7 +895,7 @@ class test_API(ClassChecker): """ Test the `ipalib.plugable.API.load_plugins` method. """ - (o, home) = self.new() + (o, home) = get_api() assert o.isdone('bootstrap') is False assert o.isdone('load_plugins') is False o.load_plugins() |