~bbaqar/charms/trusty/plumgrid-gateway/ext-interface-static

« back to all changes in this revision

Viewing changes to unit_tests/test_pg_gw_context.py

  • Committer: Bilal Ahmad
  • Date: 2015-09-10 10:41:10 UTC
  • Revision ID: bilal@plumgrid.com-20150910104110-33gs3xdqrqdfs5pa
Added code for configurable multiple gateway interfaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import charmhelpers
6
6
 
7
7
TO_PATCH = [
8
 
    'config',
9
8
    'get_unit_hostname',
10
9
]
11
10
 
22
21
 
23
22
    def setUp(self):
24
23
        super(PGGwContextTest, self).setUp(context, TO_PATCH)
25
 
        self.config.side_effect = self.test_config.get
26
 
        self.test_config.set('external-interface', 'eth1')
27
24
 
28
25
    def tearDown(self):
29
26
        super(PGGwContextTest, self).tearDown()
41
38
    @patch.object(charmhelpers.contrib.openstack.context,
42
39
                  'neutron_plugin_attribute')
43
40
    @patch.object(utils, 'check_interface_type')
44
 
    def test_neutroncc_context_api_rel(self, _int_type, _npa, _pg_dir_settings,
 
41
    @patch.object(utils, 'get_gw_interfaces')
 
42
    def test_neutroncc_context_api_rel(self, _gw_int, _int_type,
 
43
                                       _npa, _pg_dir_settings,
45
44
                                       _save_flag_file, _config_flag,
46
45
                                       _unit_get, _unit_priv_ip, _config,
47
46
                                       _is_clus, _https, _ens_pkgs):
50
49
                return "neutron.randomdriver"
51
50
            if section == "config":
52
51
                return "neutron.randomconfig"
53
 
        config = {'external-interface': "eth1"}
54
 
 
55
 
        def mock_config(key=None):
56
 
            if key:
57
 
                return config.get(key)
58
 
 
59
 
            return config
60
52
 
61
53
        self.maxDiff = None
62
 
        self.config.side_effect = mock_config
63
54
        _npa.side_effect = mock_npa
64
55
        _unit_get.return_value = '192.168.100.201'
65
56
        _unit_priv_ip.return_value = '192.168.100.201'
68
59
        _config_flag.return_value = False
69
60
        _pg_dir_settings.return_value = {'pg_dir_ip': '192.168.100.201'}
70
61
        _int_type.return_value = 'juju-br0'
 
62
        _gw_int.return_value = ['eth1']
71
63
        napi_ctxt = context.PGGwContext()
72
64
        expect = {
73
 
            'ext_interface': "eth1",
 
65
            'ext_interfaces': ['eth1'],
74
66
            'config': 'neutron.randomconfig',
75
67
            'core_plugin': 'neutron.randomdriver',
76
68
            'local_ip': 'pg_dir_ip',