~ionutbalutoiu/charms/trusty/neutron-api/next

« back to all changes in this revision

Viewing changes to unit_tests/test_actions_openstack_upgrade.py

  • Committer: David Ames
  • Date: 2015-09-25 16:09:26 UTC
  • mto: This revision was merged to the branch mainline in revision 146.
  • Revision ID: david.ames@canonical.com-20150925160926-1n0l1p7hqsu3tzeb
Action managed upgrade

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from mock import patch
 
2
import os
 
3
 
 
4
os.environ['JUJU_UNIT_NAME'] = 'neutron-api'
 
5
 
 
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
 
10
 
 
11
from test_utils import (
 
12
    CharmTestCase
 
13
)
 
14
 
 
15
TO_PATCH = [
 
16
    'do_openstack_upgrade',
 
17
    'config_changed',
 
18
]
 
19
 
 
20
 
 
21
class TestNeutronAPIUpgradeActions(CharmTestCase):
 
22
 
 
23
    def setUp(self):
 
24
        super(TestNeutronAPIUpgradeActions, self).setUp(openstack_upgrade,
 
25
                                                        TO_PATCH)
 
26
 
 
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,
 
32
                                    action_set, config):
 
33
        git_requested.return_value = False
 
34
        upgrade_avail.return_value = True
 
35
        config.return_value = True
 
36
 
 
37
        openstack_upgrade.openstack_upgrade()
 
38
 
 
39
        self.assertTrue(self.do_openstack_upgrade.called)
 
40
        self.assertTrue(self.config_changed.called)
 
41
 
 
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,
 
47
                                     action_set, config):
 
48
        git_requested.return_value = False
 
49
        upgrade_avail.return_value = True
 
50
        config.return_value = False
 
51
 
 
52
        openstack_upgrade.openstack_upgrade()
 
53
 
 
54
        self.assertFalse(self.do_openstack_upgrade.called)
 
55
        self.assertFalse(self.config_changed.called)