Beispiel #1
0
def test_generic_source_rendered():
    s = GenericSource('some {{placeholder}}')
    s.render({'placeholder': 'placeholder'})
    assert repr(s) == "GenericSource('some placeholder')"

    s = GenericSource(('some {{placeholder}} and some other large text '
                       'with important details that we should not include'))
    s.render({'placeholder': 'placeholder'})
    assert repr(s) == "GenericSource('some placeholder ...should not include')"
Beispiel #2
0
def test_hot_reload_generic_source(tmp_directory):
    path = Path(tmp_directory, 'script.sql')
    path.write_text('/*doc*/\n{{product}}')

    source = GenericSource(path, hot_reload=True)
    source.render({'product': 'some_table'})

    assert str(source) == '/*doc*/\nsome_table'
    assert source.variables == {'product'}

    path.write_text('/*new doc*/\n{{product}} {{new_tag}}')
    source.render({'product': 'some_table', 'new_tag': 'modified'})

    assert str(source) == '/*new doc*/\nsome_table modified'
    assert source.variables == {'product', 'new_tag'}