Switch bind9 agent to a driver based implementation.

Fixes bug #1074091
Fixes bug #1077023

Change-Id: I2d3077fcc38c33a0a4916c935ffad6ab63f73e7b
This commit is contained in:
Kiall Mac Innes
2012-11-08 20:39:22 +00:00
parent e8e457db4e
commit e199113a96
20 changed files with 437 additions and 55 deletions

View File

@@ -0,0 +1,59 @@
# Copyright 2012 Managed I.T.
#
# Author: Kiall Mac Innes <kiall@managedit.ie>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import tempfile
from jinja2 import Template
from moniker.tests import TestCase
from moniker import exceptions
from moniker import utils
class TestUtils(TestCase):
def test_load_template(self):
name = 'bind9-config.jinja2'
template = utils.load_template(name)
self.assertIsInstance(template, Template)
def test_load_template_missing(self):
name = 'invalid.jinja2'
with self.assertRaises(exceptions.TemplateNotFound):
utils.load_template(name)
def test_render_template(self):
template = Template("Hello {{name}}")
result = utils.render_template(template, name="World")
self.assertEqual('Hello World', result)
def render_template_to_file(self):
output_path = tempfile.mktemp()
template = Template("Hello {{name}}")
utils.render_template_to_file(template, output_path=output_path,
name="World")
self.assertTrue(os.path.exists(output_path))
try:
with open(output_path, 'r') as fh:
self.assertEqual('Hello World', fh.read())
finally:
os.unlink(output_path)