Esempio 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(),
    }
Esempio 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(),
    }
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)