How to use the lucidity.Template function in Lucidity

To help you get started, we’ve selected a few Lucidity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_invalid_pattern(pattern):
    '''Construct template with invalid pattern.'''
    with pytest.raises(ValueError):
        Template('test', pattern)
github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_anchor(path, anchor, expected):
    '''Parse path with specific anchor setting.'''
    pattern = '/static/{variable}'
    template = Template('test', pattern, anchor=anchor)

    if not expected:
        with pytest.raises(ParseError):
            template.parse(path)
    else:
        data = template.parse(path)
        assert data == {'variable': 'value'}
github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_format(pattern, data, expected):
    '''Format data against pattern.'''
    template = Template('test', pattern)
    formatted = template.format(data)
    assert formatted == expected
github 4degrees / lucidity / test / unit / test_lucidity.py View on Github external
def templates():
    '''Return candidate templates.'''
    return [
        lucidity.Template('model', '/jobs/{job.code}/assets/model/{lod}'),
        lucidity.Template('rig', '/jobs/{job.code}/assets/rig/{rig_type}')
    ]
github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_matching_parse(pattern, path, expected):
    '''Extract data from matching path.'''
    template = Template('test', pattern)
    data = template.parse(path)
    assert data == expected
github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_non_matching_parse(pattern, path):
    '''Extract data from non-matching path.'''
    template = Template('test', pattern)
    with pytest.raises(ParseError):
        data = template.parse(path)
github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_repr():
    '''Represent template.'''
    assert (repr(Template('test', '/foo/{bar}/{baz:\d+}'))
            == 'Template(name=\'test\', pattern=\'/foo/{bar}/{baz:\\\d+}\')')
github 4degrees / lucidity / test / unit / test_template.py View on Github external
def test_valid_pattern(pattern):
    '''Construct template with valid pattern.'''
    Template('test', pattern)