Exemplo n.º 1
0
def test_load_targets(target):
    stream = StringIO()
    yaml.dump(
        {
            'targets': {
                'foo': {
                    'template_name': 'foo.txt.tpl',
                    'filename': 'foo.txt',
                    'scopes': {
                        'path': 'path',
                    },
                },
            },
        }, stream)
    stream.seek(0)
    index = Index.load('', stream)
    target.assert_called_once_with(
        filename='foo.txt',
        template_name='foo.txt.tpl',
        scopes={
            'path': Scope(['path']),
        },
    )
    assert index.targets == {
        'foo': target(),
    }
Exemplo n.º 2
0
def test_load_targets(target):
    stream = StringIO()
    yaml.dump({
        'targets': {
            'foo': {
                'template_name': 'foo.txt.tpl',
                'filename': 'foo.txt',
                'scopes': {
                    'path': 'path',
                },
            },
        },
    }, stream)
    stream.seek(0)
    index = Index.load('', stream)
    target.assert_called_once_with(
        filename='foo.txt',
        template_name='foo.txt.tpl',
        scopes={
            'path': Scope(['path']),
        },
    )
    assert index.targets == {
        'foo': target(),
    }
Exemplo n.º 3
0
def test_load_no_template_paths():
    stream = StringIO()
    yaml.dump({}, stream)
    stream.seek(0)
    index = Index.load('', stream)
    assert index.targets == {}
    assert index.environment.keep_trailing_newline
    assert isinstance(index.environment.loader, FileSystemLoader)
Exemplo n.º 4
0
def test_load_no_template_paths():
    stream = StringIO()
    yaml.dump({}, stream)
    stream.seek(0)
    index = Index.load('', stream)
    assert index.targets == {}
    assert index.environment.keep_trailing_newline
    assert isinstance(index.environment.loader, FileSystemLoader)
Exemplo n.º 5
0
def test_load_template_paths():
    stream = StringIO()
    yaml.dump({
        'template_paths': {
            'foo': 'foo',
            'bar': 'bar',
        },
    }, stream)
    stream.seek(0)
    index = Index.load('', stream)
    assert index.targets == {}
    assert index.environment.keep_trailing_newline
    assert isinstance(index.environment.loader, PrefixLoader)
Exemplo n.º 6
0
def test_load_template_paths():
    stream = StringIO()
    yaml.dump({
        'template_paths': {
            'foo': 'foo',
            'bar': 'bar',
        },
    }, stream)
    stream.seek(0)
    index = Index.load('', stream)
    assert index.targets == {}
    assert index.environment.keep_trailing_newline
    assert isinstance(index.environment.loader, PrefixLoader)