Skip to content

Commit f4a404a

Browse files
committed
add test
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
1 parent 7b8bb00 commit f4a404a

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

unit_tests/sources/declarative/interpolation/test_macros.py

+38-15
Original file line numberDiff line numberDiff line change
@@ -30,68 +30,91 @@ def test_macros_export(test_name, fn_name, found_in_macros):
3030

3131

3232
@pytest.mark.parametrize(
33-
"test_name, input_value, format, input_format, expected_output",
33+
"input_value, format, input_format, expected_output",
3434
[
35-
("test_datetime_string_to_date", "2022-01-01T01:01:01Z", "%Y-%m-%d", None, "2022-01-01"),
36-
("test_date_string_to_date", "2022-01-01", "%Y-%m-%d", None, "2022-01-01"),
37-
("test_datetime_string_to_date", "2022-01-01T00:00:00Z", "%Y-%m-%d", None, "2022-01-01"),
35+
("2022-01-01T01:01:01Z", "%Y-%m-%d", None, "2022-01-01"),
36+
("2022-01-01", "%Y-%m-%d", None, "2022-01-01"),
37+
("2022-01-01T00:00:00Z", "%Y-%m-%d", None, "2022-01-01"),
3838
(
39-
"test_datetime_with_tz_string_to_date",
4039
"2022-01-01T00:00:00Z",
4140
"%Y-%m-%d",
4241
None,
4342
"2022-01-01",
4443
),
4544
(
46-
"test_datetime_string_to_datetime",
4745
"2022-01-01T01:01:01Z",
4846
"%Y-%m-%dT%H:%M:%SZ",
4947
None,
5048
"2022-01-01T01:01:01Z",
5149
),
5250
(
53-
"test_datetime_string_with_tz_to_datetime",
5451
"2022-01-01T01:01:01-0800",
5552
"%Y-%m-%dT%H:%M:%SZ",
5653
None,
5754
"2022-01-01T09:01:01Z",
5855
),
5956
(
60-
"test_datetime_object_tz_to_date",
6157
datetime.datetime(2022, 1, 1, 1, 1, 1),
6258
"%Y-%m-%d",
6359
None,
6460
"2022-01-01",
6561
),
6662
(
67-
"test_datetime_object_tz_to_datetime",
6863
datetime.datetime(2022, 1, 1, 1, 1, 1),
6964
"%Y-%m-%dT%H:%M:%SZ",
7065
None,
7166
"2022-01-01T01:01:01Z",
7267
),
7368
(
74-
"test_datetime_string_to_rfc2822_date",
7569
"Sat, 01 Jan 2022 01:01:01 +0000",
7670
"%Y-%m-%d",
7771
"%a, %d %b %Y %H:%M:%S %z",
7872
"2022-01-01",
7973
),
74+
(
75+
"2022-01-01T01:01:01Z",
76+
"%s",
77+
"%Y-%m-%dT%H:%M:%SZ",
78+
"1640995261",
79+
),
80+
(
81+
"2022-01-01T01:01:01Z",
82+
"%ms",
83+
"%Y-%m-%dT%H:%M:%SZ",
84+
"1640995261000000",
85+
),
86+
],
87+
ids=[
88+
"test_datetime_string_to_date",
89+
"test_date_string_to_date",
90+
"test_datetime_string_to_date",
91+
"test_datetime_with_tz_string_to_date",
92+
"test_datetime_string_to_datetime",
93+
"test_datetime_string_with_tz_to_datetime",
94+
"test_datetime_object_tz_to_date",
95+
"test_datetime_object_tz_to_datetime",
96+
"test_datetime_string_to_rfc2822_date",
97+
"test_datetime_string_to_timestamp_in_seconds",
98+
"test_datetime_string_to_timestamp_in_microseconds",
8099
],
81100
)
82-
def test_format_datetime(test_name, input_value, format, input_format, expected_output):
101+
def test_format_datetime(input_value, format, input_format, expected_output):
83102
format_datetime = macros["format_datetime"]
84103
assert format_datetime(input_value, format, input_format) == expected_output
85104

86105

87106
@pytest.mark.parametrize(
88-
"test_name, input_value, expected_output",
107+
"input_value, expected_output",
89108
[
90-
("test_one_day", "P1D", datetime.timedelta(days=1)),
91-
("test_6_days_23_hours", "P6DT23H", datetime.timedelta(days=6, hours=23)),
109+
("P1D", datetime.timedelta(days=1)),
110+
("P6DT23H", datetime.timedelta(days=6, hours=23)),
111+
],
112+
ids=[
113+
"test_one_day",
114+
"test_6_days_23_hours",
92115
],
93116
)
94-
def test_duration(test_name, input_value, expected_output):
117+
def test_duration(input_value: str, expected_output: datetime.timedelta):
95118
duration_fn = macros["duration"]
96119
assert duration_fn(input_value) == expected_output
97120

0 commit comments

Comments
 (0)