adding tests

This commit is contained in:
BJ Dierkes 2010-03-07 15:13:41 -06:00
parent 19b8ae4741
commit 9cffbba7e5
6 changed files with 22 additions and 5 deletions

View File

@ -1,7 +1,11 @@
0.7.3 - unreleased
-----------------------------------------------------------------------------
+ Paster now creates 'yourapp-plugin-yourplugin' rather than a plural
'-plugins-' which is more standard.
+ Removed bogus hooks: bootstrap_application_hook, bootstrap_plugins_hook
0.7.2 - Mar 06, 2010
-----------------------------------------------------------------------------

View File

@ -4,6 +4,7 @@ import sys
from pkg_resources import get_distribution
from cement import namespaces, buf_stdout, buf_stderr, SAVED_STDOUT, SAVED_STDERR
from cement.core.exc import CementConfigError
from cement.core.configuration import CEMENT_API, set_config_opts_per_file
from cement.core.configuration import validate_config, get_default_config
from cement.core.plugin import load_all_plugins
@ -41,8 +42,6 @@ def register_default_hooks():
define_hook('validate_config_hook')
define_hook('pre_plugins_hook')
define_hook('post_plugins_hook')
define_hook('bootstrap_application_hook')
define_hook('bootstrap_plugins_hook')
def lay_cement(config=None, banner=None):
"""
@ -69,6 +68,13 @@ def lay_cement(config=None, banner=None):
"""
global namespaces
try:
assert config, "default config required!"
except AssertionError, e:
raise CementConfigError, e.message
validate_config(config)
if not banner:
banner = "%s version %s" % (
config['app_name'],

View File

@ -11,6 +11,7 @@ def get_default_config():
"""Get a default config dict."""
dcf = ConfigObj()
dcf['config_source'] = ['defaults']
dcf['config_files'] = []
dcf['enabled_plugins'] = []
dcf['debug'] = False
dcf['show_plugin_load'] = True
@ -55,7 +56,7 @@ def ensure_api_compat(module_name, required_api):
"""
if required_api == CEMENT_API:
pass
return True
else:
raise CementRuntimeError, \
"%s requires Cement(api:%s) which differs from installed Cement(api:%s)." % \
@ -214,7 +215,7 @@ def validate_config(config):
required_settings = [
'config_source', 'config_files', 'debug', 'datadir',
'enabled_plugins', 'plugin_config_dir', 'app_module', 'app_name',
'tmpdir', 'merge_root_options', 'output_engine'
'tmpdir', 'output_engine'
]
for s in required_settings:
if not config.has_key(s):

View File

@ -6,6 +6,9 @@ from cement.core.log import get_logger
log = get_logger(__name__)
def clear_hooks():
hooks = {}
def define_hook(name):
"""
Define a hook namespace that plugins can register hooks in.

View File

@ -12,6 +12,9 @@ from cement.core.opt import init_parser
log = get_logger(__name__)
def clear_namespaces():
namespaces = {}
def get_namespace(namespace):
"""
Return the namespace object whose label is 'namespace'.

0
tests/__init__.py Normal file
View File