[dosaboy] fixed unit test

This commit is contained in:
Edward Hope-Morley 2014-02-17 23:50:56 +00:00
parent a6d984e9ad
commit 9977f46af6

View File

@ -9,7 +9,7 @@ TO_PATCH = [
'relation_ids',
'is_relation_made',
'service_name',
'determine_haproxy_port',
'determine_apache_port',
'determine_api_port',
]
@ -41,16 +41,24 @@ class TestGlanceContexts(CharmTestCase):
{'rbd_pool': service,
'rbd_user': service})
def test_haproxy_configuration(self):
self.determine_haproxy_port.return_value = 9292
self.determine_api_port.return_value = 9282
self.assertEquals(
contexts.HAProxyContext()(),
{'service_ports': {'glance_api': [9292, 9282]},
'bind_port': 9282})
@patch('charmhelpers.contrib.openstack.context.determine_apache_port')
@patch('charmhelpers.contrib.openstack.context.determine_api_port')
@patch('charmhelpers.contrib.openstack.context.unit_get')
@patch('charmhelpers.contrib.openstack.context.https')
def test_apache_ssl_context_service_enabled(self,
https):
https.return_value = False
self.assertEquals(contexts.ApacheSSLContext()(), {})
def test_apache_ssl_context_service_enabled(self, mock_https,
mock_unit_get,
mock_determine_api_port,
mock_determine_apache_port):
mock_https.return_value = True
mock_unit_get.return_value = '1.2.3.4'
mock_determine_api_port.return_value = '12'
mock_determine_apache_port.return_value = '34'
ctxt = contexts.ApacheSSLContext()
with patch.object(ctxt, 'enable_modules') as mock_enable_modules:
with patch.object(ctxt, 'configure_cert') as mock_configure_cert:
self.assertEquals(ctxt(), {'endpoints': [(34, 12)],
'private_address': '1.2.3.4',
'namespace': 'glance'})
self.assertTrue(mock_https.called)
mock_unit_get.assert_called_with('private-address')