Skip to content

Commit 3bee864

Browse files
committed
update test and examples
1 parent 31aa51a commit 3bee864

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3751,6 +3751,9 @@ interpolation:
37513751
return_type: datetime.datetime
37523752
examples:
37533753
- "{{ str_to_datetime('2022-01-14') }}"
3754+
- "{{ str_to_datetime('2022-01-01 13:45:30') }}"
3755+
- "{{ str_to_datetime('2022-01-01T13:45:30+00:00') }}"
3756+
- "{{ str_to_datetime('2022-01-01T13:45:30.123456Z') }}"
37543757
filters:
37553758
- title: hash
37563759
description: Convert the specified value to a hashed string.

unit_tests/sources/declarative/interpolation/test_macros.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,27 @@ def test_utc_datetime_to_local_timestamp_conversion():
140140
"2022-01-01T13:45:30+00:00",
141141
datetime.datetime(2022, 1, 1, 13, 45, 30, tzinfo=datetime.timezone.utc),
142142
),
143+
(
144+
"test_datetime_with_timezone_offset",
145+
"2022-01-01T13:45:30+05:30",
146+
datetime.datetime(2022, 1, 1, 8, 15, 30, tzinfo=datetime.timezone.utc),
147+
),
148+
(
149+
"test_datetime_with_microseconds",
150+
"2022-01-01T13:45:30.123456Z",
151+
datetime.datetime(2022, 1, 1, 13, 45, 30, 123456, tzinfo=datetime.timezone.utc),
152+
),
143153
],
144154
)
145-
def test_str_to_datetime(test_name, input_value, expected_output):
155+
def test_give_valid_date_str_to_datetime_returns_datetime_object(
156+
test_name, input_value, expected_output
157+
):
146158
str_to_datetime_fn = macros["str_to_datetime"]
147159
actual_output = str_to_datetime_fn(input_value)
148160
assert actual_output == expected_output
161+
162+
163+
def test_given_invalid_date_str_to_datetime_raises_value_error():
164+
str_to_datetime_fn = macros["str_to_datetime"]
165+
with pytest.raises(ValueError):
166+
str_to_datetime_fn("invalid-date")

0 commit comments

Comments
 (0)