moar fixes.
This commit is contained in:
parent
253af72cdf
commit
b383a1d1e7
@ -1,7 +1,6 @@
|
|||||||
from mock import patch, MagicMock
|
from mock import patch, MagicMock
|
||||||
|
|
||||||
with patch('charmhelpers.core.hookenv.config') as config:
|
from hooks import glance_contexts as contexts
|
||||||
from hooks import glance_contexts as contexts
|
|
||||||
|
|
||||||
|
|
||||||
from test_utils import (
|
from test_utils import (
|
||||||
@ -9,6 +8,7 @@ from test_utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
TO_PATCH = [
|
TO_PATCH = [
|
||||||
|
"config",
|
||||||
'relation_ids',
|
'relation_ids',
|
||||||
'is_relation_made',
|
'is_relation_made',
|
||||||
'service_name',
|
'service_name',
|
||||||
@ -21,6 +21,9 @@ class TestGlanceContexts(CharmTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestGlanceContexts, self).setUp(contexts, TO_PATCH)
|
super(TestGlanceContexts, self).setUp(contexts, TO_PATCH)
|
||||||
|
from charmhelpers.core.hookenv import cache
|
||||||
|
self.cache = cache
|
||||||
|
cache.clear()
|
||||||
|
|
||||||
def test_swift_not_related(self):
|
def test_swift_not_related(self):
|
||||||
self.relation_ids.return_value = []
|
self.relation_ids.return_value = []
|
||||||
@ -58,48 +61,38 @@ class TestGlanceContexts(CharmTestCase):
|
|||||||
{'known_stores': "glance.store.filesystem.Store,"
|
{'known_stores': "glance.store.filesystem.Store,"
|
||||||
"glance.store.http.Store"})
|
"glance.store.http.Store"})
|
||||||
|
|
||||||
@patch('charmhelpers.contrib.openstack.context.config')
|
@patch('charmhelpers.contrib.hahelpers.cluster.config_get')
|
||||||
@patch('charmhelpers.contrib.openstack.context.is_clustered')
|
|
||||||
@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')
|
@patch('charmhelpers.contrib.openstack.context.https')
|
||||||
def test_apache_ssl_context_service_enabled(self, mock_https,
|
def test_apache_ssl_context_service_enabled(self, mock_https,
|
||||||
mock_unit_get,
|
|
||||||
mock_determine_api_port,
|
|
||||||
mock_determine_apache_port,
|
|
||||||
mock_is_clustered,
|
|
||||||
mock_config):
|
mock_config):
|
||||||
|
mock_config.return_value = 'true'
|
||||||
mock_https.return_value = True
|
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'
|
|
||||||
mock_is_clustered.return_value = False
|
|
||||||
|
|
||||||
ctxt = contexts.ApacheSSLContext()
|
ctxt = contexts.ApacheSSLContext()
|
||||||
ctxt.enable_modules = MagicMock()
|
ctxt.enable_modules = MagicMock()
|
||||||
ctxt.configure_cert = MagicMock()
|
ctxt.configure_cert = MagicMock()
|
||||||
ctxt.configure_ca = MagicMock()
|
ctxt.configure_ca = MagicMock()
|
||||||
ctxt.canonical_names = MagicMock()
|
ctxt.canonical_names = MagicMock()
|
||||||
self.assertEquals(ctxt(), {'endpoints': [('1.2.3.4', '1.2.3.4',
|
ctxt.get_network_addresses = MagicMock()
|
||||||
34, 12)],
|
ctxt.get_network_addresses.return_value = [('1.2.3.4', '1.2.3.4')]
|
||||||
'ext_ports': [34],
|
|
||||||
'namespace': 'glance'})
|
|
||||||
self.assertTrue(mock_https.called)
|
|
||||||
mock_unit_get.assert_called_with('private-address')
|
|
||||||
|
|
||||||
@patch('hooks.glance_contexts.config')
|
self.assertEquals(ctxt(), {'endpoints': [('1.2.3.4', '1.2.3.4',
|
||||||
def test_glance_ipv6_context_service_enabled(self, mock_context_config):
|
9282, 9272)],
|
||||||
config.return_value = True
|
'ext_ports': [9282],
|
||||||
mock_context_config.return_value = True
|
'namespace': 'glance'})
|
||||||
|
|
||||||
|
@patch("charmhelpers.core.hookenv.subprocess.check_output")
|
||||||
|
def test_glance_ipv6_context_service_enabled(self, mock_subprocess):
|
||||||
|
self.config.return_value = True
|
||||||
|
mock_subprocess.return_value = 'true'
|
||||||
ctxt = contexts.GlanceIPv6Context()
|
ctxt = contexts.GlanceIPv6Context()
|
||||||
self.assertEquals(ctxt(), {'bind_host': '::',
|
self.assertEquals(ctxt(), {'bind_host': '::',
|
||||||
'registry_host': '[::]'})
|
'registry_host': '[::]'})
|
||||||
|
|
||||||
@patch('hooks.glance_contexts.config')
|
@patch("charmhelpers.core.hookenv.subprocess.check_output")
|
||||||
def test_glance_ipv6_context_service_disabled(self, mock_context_config):
|
def test_glance_ipv6_context_service_disabled(self, mock_subprocess):
|
||||||
config.return_value = False
|
self.config.return_value = False
|
||||||
mock_context_config.return_value = False
|
mock_subprocess.return_value = 'false'
|
||||||
ctxt = contexts.GlanceIPv6Context()
|
ctxt = contexts.GlanceIPv6Context()
|
||||||
self.assertEquals(ctxt(), {'bind_host': '0.0.0.0',
|
self.assertEquals(ctxt(), {'bind_host': '0.0.0.0',
|
||||||
'registry_host': '0.0.0.0'})
|
'registry_host': '0.0.0.0'})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user