Move config_changed into try block

This commit is contained in:
Corey Bryant 2015-04-15 16:37:51 +00:00
parent 1dd661396d
commit b4f7e8e0e8
3 changed files with 14 additions and 7 deletions

View File

@ -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()

View File

@ -45,22 +45,27 @@ class TestNeutronOVSActions(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()
@ -73,10 +78,12 @@ class TestNeutronOVSActions(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

View File

@ -101,7 +101,7 @@ class OVSPluginContextTest(CharmTestCase):
return config
self.maxDiff = None
self.config.side_effect = mock_config
self.config.side_effect = mock_config
_npa.side_effect = mock_npa
_unit_get.return_value = '127.0.0.13'
_unit_priv_ip.return_value = '127.0.0.14'