Extent Config test coverage, and make del_profile() more robust

This commit is contained in:
Chris Jones 2010-01-14 23:29:47 +00:00
parent ddadf3486f
commit 62d5672a88
1 changed files with 17 additions and 1 deletions

View File

@ -44,6 +44,19 @@ Classes relating to configuration
{'foo': 'bar'} {'foo': 'bar'}
>>> config.plugin_get('testplugin', 'foo') >>> config.plugin_get('testplugin', 'foo')
'bar' 'bar'
>>> config.get_profile()
'default'
>>> config.set_profile('my_first_new_testing_profile')
>>> config.get_profile()
'my_first_new_testing_profile'
>>> config.del_profile('my_first_new_testing_profile')
>>> config.get_profile()
'default'
>>> config.list_profiles().__class__.__name__
'list'
>>> config.options_set({})
>>> config.options_get()
{}
>>> >>>
""" """
@ -220,6 +233,9 @@ class Config(object):
def del_profile(self, profile): def del_profile(self, profile):
"""Delete a profile""" """Delete a profile"""
if profile == self.profile:
err('Config::del_profile: Deleting in-use profile %s.' % profile)
self.set_profile('default')
if self.base.profiles.has_key(profile): if self.base.profiles.has_key(profile):
del(self.base.profiles[profile]) del(self.base.profiles[profile])