예제 #1
0
def test_render_missing_key(examples):
    target_dir, fs_examples = examples
    with raises(KeyError):
        render_template(path.join(fs_examples,
                'unbound/usr/local/etc/unbound/unbound.conf.tmpl'),
            target_dir,
            dict())
예제 #2
0
def test_render_copy(examples):
    """if the source is not a template, it is copied."""
    target_dir, fs_examples = examples
    fs_source = path.join(fs_examples, 'unbound/etc/rc.conf')
    fs_rendered = render_template(fs_source,
        target_dir,
        dict(ip_addr='192.168.0.1', access_control='10.0.1.0/16 allow'))
    assert fs_rendered.endswith('/rc.conf')
    assert (cmp(fs_source, fs_rendered))
예제 #3
0
def test_render_template(examples):
    """if the source is a template, it is rendered and the target file drops
    the `.tmpl` suffix."""
    target_dir, fs_examples = examples
    fs_rendered = render_template(path.join(fs_examples,
            'unbound/usr/local/etc/unbound/unbound.conf.tmpl'),
        target_dir,
        dict(ip_addr='192.168.0.1', access_control='10.0.1.0/16 allow'))
    assert fs_rendered.endswith('/unbound.conf')
    assert ('interface: 192.168.0.1' in open(fs_rendered).read())