@@ -65,6 +65,18 @@ def test_create_event_timestamp_filter_when_given_both_begin_and_end_builds_expe
6565 assert actual_end == expected_end
6666
6767
68+ def test_create_event_timestamp_filter_when_given_short_time_args_builds_expected_query ():
69+ begin_date = "{} 10" .format (begin_date_str )
70+ end_date = "{} 12:37" .format (end_date_str )
71+ ts_range = create_event_timestamp_filter (begin_date , end_date )
72+ actual_begin = get_filter_value_from_json (ts_range , filter_index = 0 )
73+ actual_end = get_filter_value_from_json (ts_range , filter_index = 1 )
74+ expected_begin = "{0}T10:00:00.000Z" .format (begin_date_str )
75+ expected_end = "{0}T12:37:00.000Z" .format (end_date_str )
76+ assert actual_begin == expected_begin
77+ assert actual_end == expected_end
78+
79+
6880def test_create_event_timestamp_filter_when_begin_more_than_ninety_days_back_causes_value_error ():
6981 begin_date_str = get_test_date_str (days_ago = 91 )
7082 with pytest .raises (DateArgumentException ):
@@ -90,22 +102,18 @@ def test_create_event_timestamp_filter_when_args_are_magic_days_builds_expected_
90102 assert actual_end == expected_end
91103
92104
93- def test_create_event_timestamp_filter_when_given_improperly_formatted_arg_raises_value_error ():
94- missing_seconds = "{} {}" .format (get_test_date_str (days_ago = 5 ), "12:00" )
95- month_first_date = "01-01-2020"
96- time_typo = "{} {}" .format (get_test_date_str (days_ago = 5 ), "b20:30:00" )
97- bad_magic = "2months"
98- bad_magic_2 = "100s"
99- bad_magic_3 = "10 d"
100- with pytest .raises (DateArgumentException ):
101- create_event_timestamp_filter (missing_seconds )
102- with pytest .raises (DateArgumentException ):
103- create_event_timestamp_filter (month_first_date )
104- with pytest .raises (DateArgumentException ):
105- create_event_timestamp_filter (time_typo )
106- with pytest .raises (DateArgumentException ):
107- create_event_timestamp_filter (bad_magic )
108- with pytest .raises (DateArgumentException ):
109- create_event_timestamp_filter (bad_magic_2 )
105+ @pytest .mark .parametrize (
106+ "bad_date_param" ,
107+ [
108+ "01-01-2020" ,
109+ "{} {}" .format (get_test_date_str (days_ago = 5 ), "b20:30:00" ),
110+ "2months" ,
111+ "100s" ,
112+ "10 d" ,
113+ ],
114+ )
115+ def test_create_event_timestamp_filter_when_given_improperly_formatted_arg_raises_value_error (
116+ bad_date_param ,
117+ ):
110118 with pytest .raises (DateArgumentException ):
111- create_event_timestamp_filter (bad_magic_3 )
119+ create_event_timestamp_filter (bad_date_param )
0 commit comments