Move config_changed into try block
This commit is contained in:
parent
1ddd84f497
commit
a290c50838
@ -35,6 +35,7 @@ def git_reinstall():
|
||||
|
||||
try:
|
||||
git_install(config('openstack-origin-git'))
|
||||
config_changed()
|
||||
except:
|
||||
action_set({'traceback': traceback.format_exc()})
|
||||
action_fail('git-reinstall resulted in an unexpected error')
|
||||
@ -42,4 +43,3 @@ def git_reinstall():
|
||||
|
||||
if __name__ == '__main__':
|
||||
git_reinstall()
|
||||
config_changed()
|
||||
|
@ -49,9 +49,10 @@ class TestCinderActions(CharmTestCase):
|
||||
@patch.object(git_reinstall, 'action_set')
|
||||
@patch.object(git_reinstall, 'action_fail')
|
||||
@patch.object(git_reinstall, 'git_install')
|
||||
@patch.object(git_reinstall, 'config_changed')
|
||||
@patch('charmhelpers.contrib.openstack.utils.config')
|
||||
def test_git_reinstall(self, _config, git_install, action_fail,
|
||||
action_set):
|
||||
def test_git_reinstall(self, _config, config_changed, git_install,
|
||||
action_fail, action_set):
|
||||
_config.return_value = openstack_origin_git
|
||||
self.test_config.set('openstack-origin-git', openstack_origin_git)
|
||||
|
||||
@ -59,15 +60,18 @@ class TestCinderActions(CharmTestCase):
|
||||
|
||||
git_install.assert_called_with(openstack_origin_git)
|
||||
self.assertTrue(git_install.called)
|
||||
self.assertTrue(config_changed.called)
|
||||
self.assertFalse(action_set.called)
|
||||
self.assertFalse(action_fail.called)
|
||||
|
||||
@patch.object(git_reinstall, 'action_set')
|
||||
@patch.object(git_reinstall, 'action_fail')
|
||||
@patch.object(git_reinstall, 'git_install')
|
||||
@patch.object(git_reinstall, 'config_changed')
|
||||
@patch('charmhelpers.contrib.openstack.utils.config')
|
||||
def test_git_reinstall_not_configured(self, _config, git_install,
|
||||
action_fail, action_set):
|
||||
def test_git_reinstall_not_configured(self, _config, config_changed,
|
||||
git_install, action_fail,
|
||||
action_set):
|
||||
_config.return_value = None
|
||||
|
||||
git_reinstall.git_reinstall()
|
||||
@ -80,10 +84,11 @@ class TestCinderActions(CharmTestCase):
|
||||
@patch.object(git_reinstall, 'action_set')
|
||||
@patch.object(git_reinstall, 'action_fail')
|
||||
@patch.object(git_reinstall, 'git_install')
|
||||
@patch.object(git_reinstall, 'config_changed')
|
||||
@patch('traceback.format_exc')
|
||||
@patch('charmhelpers.contrib.openstack.utils.config')
|
||||
def test_git_reinstall_exception(self, _config, format_exc, git_install,
|
||||
action_fail, action_set):
|
||||
def test_git_reinstall_exception(self, _config, format_exc, config_changed,
|
||||
git_install, action_fail, action_set):
|
||||
_config.return_value = openstack_origin_git
|
||||
e = OSError('something bad happened')
|
||||
git_install.side_effect = e
|
||||
|
Loading…
Reference in New Issue
Block a user