Move config_changed into try block

This commit is contained in:
Corey Bryant 2015-04-15 16:35:29 +00:00
parent bc259a9de7
commit 39189932bc
2 changed files with 13 additions and 6 deletions

View File

@ -35,6 +35,7 @@ def git_reinstall():
try: try:
git_install(config('openstack-origin-git')) git_install(config('openstack-origin-git'))
config_changed()
except: except:
action_set({'traceback': traceback.format_exc()}) action_set({'traceback': traceback.format_exc()})
action_fail('git-reinstall resulted in an unexpected error') action_fail('git-reinstall resulted in an unexpected error')
@ -42,4 +43,3 @@ def git_reinstall():
if __name__ == '__main__': if __name__ == '__main__':
git_reinstall() git_reinstall()
config_changed()

View File

@ -45,22 +45,27 @@ class TestNeutronAPIActions(CharmTestCase):
@patch.object(git_reinstall, 'action_set') @patch.object(git_reinstall, 'action_set')
@patch.object(git_reinstall, 'action_fail') @patch.object(git_reinstall, 'action_fail')
@patch.object(git_reinstall, 'git_install') @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) self.test_config.set('openstack-origin-git', openstack_origin_git)
git_reinstall.git_reinstall() git_reinstall.git_reinstall()
git_install.assert_called_with(openstack_origin_git) git_install.assert_called_with(openstack_origin_git)
self.assertTrue(git_install.called) self.assertTrue(git_install.called)
self.assertTrue(config_changed.called)
self.assertFalse(action_set.called) self.assertFalse(action_set.called)
self.assertFalse(action_fail.called) self.assertFalse(action_fail.called)
@patch.object(git_reinstall, 'action_set') @patch.object(git_reinstall, 'action_set')
@patch.object(git_reinstall, 'action_fail') @patch.object(git_reinstall, 'action_fail')
@patch.object(git_reinstall, 'git_install') @patch.object(git_reinstall, 'git_install')
@patch.object(git_reinstall, 'config_changed')
@patch('charmhelpers.contrib.openstack.utils.config') @patch('charmhelpers.contrib.openstack.utils.config')
def test_git_reinstall_not_configured(self, _config, git_install, def test_git_reinstall_not_configured(self, _config, config_changed,
action_fail, action_set): git_install, action_fail,
action_set):
_config.return_value = None _config.return_value = None
git_reinstall.git_reinstall() git_reinstall.git_reinstall()
@ -73,10 +78,12 @@ class TestNeutronAPIActions(CharmTestCase):
@patch.object(git_reinstall, 'action_set') @patch.object(git_reinstall, 'action_set')
@patch.object(git_reinstall, 'action_fail') @patch.object(git_reinstall, 'action_fail')
@patch.object(git_reinstall, 'git_install') @patch.object(git_reinstall, 'git_install')
@patch.object(git_reinstall, 'config_changed')
@patch('traceback.format_exc') @patch('traceback.format_exc')
@patch('charmhelpers.contrib.openstack.utils.config') @patch('charmhelpers.contrib.openstack.utils.config')
def test_git_reinstall_exception(self, _config, format_exc, git_install, def test_git_reinstall_exception(self, _config, format_exc,
action_fail, action_set): config_changed, git_install, action_fail,
action_set):
_config.return_value = openstack_origin_git _config.return_value = openstack_origin_git
e = OSError('something bad happened') e = OSError('something bad happened')
git_install.side_effect = e git_install.side_effect = e