Move config_changed into try block
This commit is contained in:
parent
0cd376a62c
commit
d523730fd8
@ -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()
|
||||
|
@ -47,22 +47,27 @@ class TestnovaAPIActions(CharmTestCase):
|
||||
@patch.object(git_reinstall, 'action_set')
|
||||
@patch.object(git_reinstall, 'action_fail')
|
||||
@patch.object(git_reinstall, 'git_install')
|
||||
def test_git_reinstall(self, git_install, action_fail, action_set):
|
||||
@patch.object(git_reinstall, 'config_changed')
|
||||
def test_git_reinstall(self, config_changed, git_install, action_fail,
|
||||
action_set):
|
||||
self.test_config.set('openstack-origin-git', openstack_origin_git)
|
||||
|
||||
git_reinstall.git_reinstall()
|
||||
|
||||
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()
|
||||
@ -75,10 +80,12 @@ class TestnovaAPIActions(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