1
0
mirror of synced 2026-01-14 12:07:57 -05:00
Files
airbyte/airbyte-cdk/python/unit_tests/sources/declarative/interpolation/test_macros.py
Serhii Chvaliuk dc2c61837b CDK: Add jinja macro format_datetime (#19506)
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
2022-11-18 19:18:32 +02:00

34 lines
1007 B
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
import datetime
import pytest
from airbyte_cdk.sources.declarative.interpolation.macros import macros
@pytest.mark.parametrize(
"test_name, fn_name, found_in_macros",
[
("test_now_local", "now_local", True),
("test_now_utc", "now_utc", True),
("test_today_utc", "today_utc", True),
("test_max", "max", True),
("test_day_delta", "day_delta", True),
("test_format_datetime", "format_datetime", True),
("test_not_a_macro", "thisisnotavalidmacro", False),
],
)
def test_macros_export(test_name, fn_name, found_in_macros):
if found_in_macros:
assert fn_name in macros
else:
assert fn_name not in macros
def test_format_datetime():
format_datetime = macros["format_datetime"]
assert format_datetime("2022-01-01T01:01:01Z", "%Y-%m-%d") == "2022-01-01"
assert format_datetime(datetime.datetime(2022, 1, 1, 1, 1, 1), "%Y-%m-%d") == "2022-01-01"