13
class IdentityServiceContext(CharmTestCase):
15
super(IdentityServiceContext, self).setUp(context, TO_PATCH)
16
self.relation_get.side_effect = self.test_relation.get
17
self.config.side_effect = self.test_config.get
18
self.test_config.set('region', 'region457')
20
@patch.object(charmhelpers.contrib.openstack.context, 'context_complete')
21
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
22
@patch.object(charmhelpers.contrib.openstack.context, 'related_units')
23
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
24
@patch.object(charmhelpers.contrib.openstack.context, 'log')
25
def test_ids_ctxt(self, _log, _rids, _runits, _rget, _ctxt_comp):
26
_rids.return_value = 'rid1'
27
_runits.return_value = 'runit'
28
_ctxt_comp.return_value = True
31
'service_host': '127.0.0.4',
32
'auth_host': '127.0.0.5',
34
'service_tenant': 'ten',
35
'service_username': 'admin',
36
'service_password': 'adminpass',
38
_rget.return_value = id_data
39
ids_ctxt = context.IdentityServiceContext()
40
self.assertEquals(ids_ctxt()['region'], 'region457')
42
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
43
@patch.object(charmhelpers.contrib.openstack.context, 'log')
44
def test_ids_ctxt_no_rels(self, _log, _rids):
45
_rids.return_value = []
46
ids_ctxt = context.IdentityServiceContext()
47
self.assertEquals(ids_ctxt(), None)
13
49
class NeutronAPIContextsTest(CharmTestCase):
28
64
@patch.object(context.NeutronCCContext, 'network_manager')
29
65
@patch.object(context.NeutronCCContext, 'plugin')
30
def test_quantum_plugin_context_no_setting(self, plugin, nm):
66
def test_neutroncc_context_no_setting(self, plugin, nm):
31
67
plugin.return_value = None
32
68
napi_ctxt = context.NeutronCCContext()
38
74
with patch.object(napi_ctxt, '_ensure_packages'):
39
75
self.assertEquals(ctxt_data, napi_ctxt())
41
def test_quantum_plugin_context_manager(self):
77
@patch.object(context.NeutronCCContext, 'network_manager')
78
@patch.object(context.NeutronCCContext, 'plugin')
79
def test_neutroncc_context_api_rel(self, plugin, nm):
80
nova_url = 'http://127.0.0.10'
81
plugin.return_value = None
82
self.related_units.return_value = ['unit1']
83
self.relation_ids.return_value = ['rid2']
84
self.test_relation.set({'nova_url': nova_url})
85
napi_ctxt = context.NeutronCCContext()
86
self.assertEquals(nova_url, napi_ctxt()['nova_url'])
88
def test_neutroncc_context_manager(self):
42
89
napi_ctxt = context.NeutronCCContext()
43
90
self.assertEquals(napi_ctxt.network_manager, 'neutron')
44
91
self.assertEquals(napi_ctxt.plugin, 'ovs')
45
92
self.assertEquals(napi_ctxt.neutron_security_groups, True)
47
def test_quantum_plugin_context_manager_pkgs(self):
94
def test_neutroncc_context_manager_pkgs(self):
48
95
napi_ctxt = context.NeutronCCContext()
49
96
with patch.object(napi_ctxt, '_ensure_packages') as ep:
50
97
napi_ctxt._ensure_packages()