32 lines
957 B
Python
32 lines
957 B
Python
#
|
|
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
|
#
|
|
|
|
from airbyte_cdk.sources.declarative.interpolation.jinja import JinjaInterpolation
|
|
|
|
|
|
def test_get_value_from_config():
|
|
interpolation = JinjaInterpolation()
|
|
s = "{{ config['date'] }}"
|
|
config = {"date": "2022-01-01"}
|
|
val = interpolation.eval(s, config)
|
|
assert val == "2022-01-01"
|
|
|
|
|
|
def test_get_value_from_stream_slice():
|
|
interpolation = JinjaInterpolation()
|
|
s = "{{ stream_slice['date'] }}"
|
|
config = {"date": "2022-01-01"}
|
|
stream_slice = {"date": "2020-09-09"}
|
|
val = interpolation.eval(s, config, **{"stream_slice": stream_slice})
|
|
assert val == "2020-09-09"
|
|
|
|
|
|
def test_get_value_from_a_list_of_mappings():
|
|
interpolation = JinjaInterpolation()
|
|
s = "{{ records[0]['date'] }}"
|
|
config = {"date": "2022-01-01"}
|
|
records = [{"date": "2020-09-09"}]
|
|
val = interpolation.eval(s, config, **{"records": records})
|
|
assert val == "2020-09-09"
|