Skip to content

Commit 5366b13

Browse files
maxi297aaronsteers
andauthored
fix: locally running tests errors (#459)
Co-authored-by: Aaron ("AJ") Steers <[email protected]>
1 parent 5c32297 commit 5366b13

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

airbyte_cdk/sources/declarative/interpolation/macros.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def format_datetime(
177177
dt_datetime = (
178178
datetime.datetime.strptime(dt, input_format) if input_format else str_to_datetime(dt)
179179
)
180+
if dt_datetime.tzinfo is None:
181+
dt_datetime = dt_datetime.replace(tzinfo=pytz.utc)
180182
return DatetimeParser().format(dt=dt_datetime, format=format)
181183

182184

airbyte_cdk/sources/declarative/schema/default_schema_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_json_schema(self) -> Mapping[str, Any]:
3737

3838
try:
3939
return self.default_loader.get_json_schema()
40-
except OSError:
40+
except (OSError, ValueError):
4141
# A slight hack since we don't directly have the stream name. However, when building the default filepath we assume the
4242
# runtime options stores stream name 'name' so we'll do the same here
4343
stream_name = self._parameters.get("name", "")

unit_tests/sources/declarative/interpolation/test_macros.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ def test_macros_export(test_name, fn_name, found_in_macros):
101101
"%ms",
102102
"2022-01-01T01:01:01Z",
103103
),
104+
(
105+
"2022-01-01T01:01:01+0100",
106+
"%Y-%m-%dT%H:%M:%S.%f%z",
107+
None,
108+
"2022-01-01T00:01:01.000000+0000",
109+
),
110+
(
111+
"2022-01-01T01:01:01",
112+
"%Y-%m-%dT%H:%M:%S.%f%z",
113+
None,
114+
"2022-01-01T01:01:01.000000+0000",
115+
),
104116
],
105117
ids=[
106118
"test_datetime_string_to_date",
@@ -117,6 +129,8 @@ def test_macros_export(test_name, fn_name, found_in_macros):
117129
"test_timestamp_to_format_string",
118130
"test_timestamp_epoch_microseconds_to_format_string",
119131
"test_timestamp_ms_to_format_string",
132+
"test_datetime_with_timezone",
133+
"test_datetime_without_timezone_then_utc_is_inferred",
120134
],
121135
)
122136
def test_format_datetime(input_value, format, input_format, expected_output):

0 commit comments

Comments
 (0)