Пример #1
0
def test_generic_source_unrendered():
    s = GenericSource('some {{placeholder}}')
    assert repr(s) == "GenericSource('some {{placeholder}}')"

    s = GenericSource(('some {{placeholder}} and some other large text '
                       'with important details that we should not include'))
    assert repr(s) == "GenericSource('some {{placeholde...should not include')"
Пример #2
0
    def _init_source(source, kwargs):
        required = {
            'product': ('ShellScript must include {{product}} in '
                        'its source')
        }

        return GenericSource(source, **kwargs, required=required)
Пример #3
0
    def _init_source(self, source):
        source = GenericSource(source)

        if source.needs_render:
            raise SourceInitializationError('The source for this task "{}"'
                                            ' must be a literal '.format(
                                                source.value.raw))

        return source
Пример #4
0
    def _init_source(self, source):
        source = GenericSource(str(source))

        if not source.needs_render:
            raise SourceInitializationError('The source for this task '
                                            'must be a template since the '
                                            'product will be passed as '
                                            'parameter')

        return source
Пример #5
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'}
Пример #6
0
 def _init_source(self, source):
     return GenericSource(str(source))
Пример #7
0
 def _init_source(source, kwargs):
     return GenericSource(str(source), **kwargs, optional=['product'])