Exemplo n.º 1
0
def test_render_multipass_concat():
    os.environ['MYENVVAR'] = '/bin/bash'
    doc = '''
        ---
        variables:
            a: "hello-{{ env('NOTFOUND_DEFAULT_VALUE', 'world') }}"
            b: "one-{{ env('MYENVVAR') }}"
            c: "two-{{ variables.b }}"
            d: "three-{{ variables.c }}"
            e: "{{ variables.c + '-plus-' + variables.d }}"
        '''

    ref = {
        'variables': {
            'a': 'hello-world',
            'b': 'one-/bin/bash',
            'c': 'two-one-/bin/bash',
            'd': 'three-two-one-/bin/bash',
            'e': 'two-one-/bin/bash-plus-three-two-one-/bin/bash'
        }
    }

    md = yaml.load(dedent(doc))
    res = reader.render(md)
    assert (res == ref)
Exemplo n.º 2
0
def test_render_multipass():
    # no multipass currently

    doc = '''
        ---
        profile: test
        resources:
            oh : '{{ profile }}'
            data:
                path: datasets/extract/{{ resources.oh }}
                format: parquet-{{ resources.oh }}
                provider: local-{{ resources.oh }}
        '''
    ref = {
        'resources': {
            'data': {
                'format': 'parquet-test',
                'path': 'datasets/extract/test',
                'provider': 'local-test'
            },
            'oh': 'test'
        },
        'profile': 'test'
    }

    md = yaml.load(dedent(doc))
    res = reader.render(md)
    assert (res == ref)
Exemplo n.º 3
0
def test_render_env():
    os.environ['MYENVVAR'] = '/bin/bash'

    doc = '''
        ---
        profile: default
        variables:
            ref: default.variables.a0
            a0: "{{ env('MYENVVAR') }}"
            c0: "{{ ''|env('MYENVVAR')}}"

            a1: "{{ env('MYENVVAR','default_value') }}"
            c1: "{{ 'default_value'|env('MYENVVAR')}}"

            a2: "{{ env('UNDEFINED_ENV', 'world') }}"
            c2: "{{ 'world'|env('UNDEFINED_ENV')}}"
        '''

    ref = {
        'profile': 'default',
        'variables': {
            'a0': '/bin/bash',
            'a1': '/bin/bash',
            'a2': 'world',
            'c0': '/bin/bash',
            'c1': '/bin/bash',
            'c2': 'world',
            'ref': 'default.variables.a0'
        }
    }

    md = yaml.load(dedent(doc))
    res = reader.render(md)
    assert (res == ref)
Exemplo n.º 4
0
def test_render():
    doc = '''
        ---
        profile: default
        resources:
            input:
                path: datasets/extract/{{ profile }}
                format: parquet
                provider: local-other
        '''

    ref = {
        'resources': {
            'input': {
                'format': 'parquet',
                'path': 'datasets/extract/default',
                'provider': 'local-other'
            }
        },
        'profile': 'default'
    }

    md = yaml.load(dedent(doc))
    res = reader.render(md)
    assert (res == ref)