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