@@ -30,68 +30,91 @@ def test_macros_export(test_name, fn_name, found_in_macros):
30
30
31
31
32
32
@pytest .mark .parametrize (
33
- "test_name, input_value, format, input_format, expected_output" ,
33
+ "input_value, format, input_format, expected_output" ,
34
34
[
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" ),
38
38
(
39
- "test_datetime_with_tz_string_to_date" ,
40
39
"2022-01-01T00:00:00Z" ,
41
40
"%Y-%m-%d" ,
42
41
None ,
43
42
"2022-01-01" ,
44
43
),
45
44
(
46
- "test_datetime_string_to_datetime" ,
47
45
"2022-01-01T01:01:01Z" ,
48
46
"%Y-%m-%dT%H:%M:%SZ" ,
49
47
None ,
50
48
"2022-01-01T01:01:01Z" ,
51
49
),
52
50
(
53
- "test_datetime_string_with_tz_to_datetime" ,
54
51
"2022-01-01T01:01:01-0800" ,
55
52
"%Y-%m-%dT%H:%M:%SZ" ,
56
53
None ,
57
54
"2022-01-01T09:01:01Z" ,
58
55
),
59
56
(
60
- "test_datetime_object_tz_to_date" ,
61
57
datetime .datetime (2022 , 1 , 1 , 1 , 1 , 1 ),
62
58
"%Y-%m-%d" ,
63
59
None ,
64
60
"2022-01-01" ,
65
61
),
66
62
(
67
- "test_datetime_object_tz_to_datetime" ,
68
63
datetime .datetime (2022 , 1 , 1 , 1 , 1 , 1 ),
69
64
"%Y-%m-%dT%H:%M:%SZ" ,
70
65
None ,
71
66
"2022-01-01T01:01:01Z" ,
72
67
),
73
68
(
74
- "test_datetime_string_to_rfc2822_date" ,
75
69
"Sat, 01 Jan 2022 01:01:01 +0000" ,
76
70
"%Y-%m-%d" ,
77
71
"%a, %d %b %Y %H:%M:%S %z" ,
78
72
"2022-01-01" ,
79
73
),
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" ,
80
99
],
81
100
)
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 ):
83
102
format_datetime = macros ["format_datetime" ]
84
103
assert format_datetime (input_value , format , input_format ) == expected_output
85
104
86
105
87
106
@pytest .mark .parametrize (
88
- "test_name, input_value, expected_output" ,
107
+ "input_value, expected_output" ,
89
108
[
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" ,
92
115
],
93
116
)
94
- def test_duration (test_name , input_value , expected_output ):
117
+ def test_duration (input_value : str , expected_output : datetime . timedelta ):
95
118
duration_fn = macros ["duration" ]
96
119
assert duration_fn (input_value ) == expected_output
97
120
0 commit comments