4
os.environ['JUJU_UNIT_NAME'] = 'neutron-api'
6
with patch('charmhelpers.core.hookenv.config') as config:
7
config.return_value = 'ovs'
8
with patch('neutron_api_utils.register_configs') as register_configs:
9
import openstack_upgrade
11
from test_utils import (
16
'do_openstack_upgrade',
21
class TestNeutronAPIUpgradeActions(CharmTestCase):
24
super(TestNeutronAPIUpgradeActions, self).setUp(openstack_upgrade,
27
@patch('charmhelpers.contrib.openstack.utils.config')
28
@patch('charmhelpers.contrib.openstack.utils.action_set')
29
@patch('charmhelpers.contrib.openstack.utils.git_install_requested')
30
@patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available')
31
def test_openstack_upgrade_true(self, upgrade_avail, git_requested,
33
git_requested.return_value = False
34
upgrade_avail.return_value = True
35
config.return_value = True
37
openstack_upgrade.openstack_upgrade()
39
self.assertTrue(self.do_openstack_upgrade.called)
40
self.assertTrue(self.config_changed.called)
42
@patch('charmhelpers.contrib.openstack.utils.config')
43
@patch('charmhelpers.contrib.openstack.utils.action_set')
44
@patch('charmhelpers.contrib.openstack.utils.git_install_requested')
45
@patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available')
46
def test_openstack_upgrade_false(self, upgrade_avail, git_requested,
48
git_requested.return_value = False
49
upgrade_avail.return_value = True
50
config.return_value = False
52
openstack_upgrade.openstack_upgrade()
54
self.assertFalse(self.do_openstack_upgrade.called)
55
self.assertFalse(self.config_changed.called)