4
from jinja2 import Environment
6
from charmhelpers.contrib.openstack.templating import get_loader
9
class ProxyServerTemplateTestCase(unittest.TestCase):
11
@mock.patch('charmhelpers.contrib.openstack.templating.log')
12
def get_template_for_release(self, os_release, mock_log):
13
loader = get_loader('./templates', os_release)
14
env = Environment(loader=loader)
16
return env.get_template('proxy-server.conf')
18
def test_essex_keystone_includes_correct_egg(self):
19
"""Regression test for bug 1251551."""
20
template = self.get_template_for_release('essex')
22
result = template.render(auth_type='keystone')
24
self.assertIn("use = egg:swift#swift3", result)
26
def test_essex_keystone_includes_correct_delay_auth_true(self):
27
"""Regression test for bug 1251551."""
28
template = self.get_template_for_release('essex')
30
result = template.render(auth_type='keystone',
31
delay_auth_decision='true')
33
self.assertIn("delay_auth_decision = 1", result)
35
def test_essex_keystone_includes_correct_delay_auth_false(self):
36
"""Regression test for bug 1251551."""
37
template = self.get_template_for_release('essex')
39
result = template.render(auth_type='keystone',
40
delay_auth_decision='anything')
42
self.assertIn("delay_auth_decision = 0", result)
44
def test_os_release_not_in_templates(self):
45
"""Regression test for bug 1251551.
47
The os_release is no longer provided as context to the templates.
49
for release in ('essex', 'grizzly', 'havana'):
50
template = self.get_template_for_release(release)
51
with open(template.filename, 'r') as template_orig:
53
'os_release', template_orig.read(),
54
"The template '{}' contains os_release which is "
55
"no longer provided in the context.".format(
58
def test_config_renders_for_all_releases(self):
59
"""The configs render without syntax error."""
60
for release in ('essex', 'grizzly', 'havana'):
61
template = self.get_template_for_release(release)
63
result = template.render()
65
self.assertTrue(result.startswith("[DEFAULT]"))