@@ -222,6 +222,78 @@ def test_get_env_vars_auth_with_github_app_installation_missing_inputs(self):
222222 "GH_APP_ID set and GH_APP_INSTALLATION_ID or GH_APP_PRIVATE_KEY variable not set" ,
223223 )
224224
225+ @patch .dict (
226+ os .environ ,
227+ {
228+ "ORGANIZATION" : "org" ,
229+ "REPOSITORY" : "repo" ,
230+ "GH_TOKEN" : "token" ,
231+ "START_DATE" : "2025-01-01" ,
232+ "END_DATE" : "2024-01-01" ,
233+ },
234+ clear = True ,
235+ )
236+ def test_get_env_vars_end_date_before_start_date (self ):
237+ """Test that an error is raised when END_DATE is before START_DATE"""
238+ with self .assertRaises (ValueError ) as cm :
239+ env .get_env_vars ()
240+ the_exception = cm .exception
241+ self .assertEqual (
242+ str (the_exception ),
243+ "END_DATE ('2024-01-01') must be after START_DATE ('2025-01-01')" ,
244+ )
245+
246+ @patch .dict (
247+ os .environ ,
248+ {
249+ "ORGANIZATION" : "org" ,
250+ "REPOSITORY" : "repo" ,
251+ "GH_TOKEN" : "token" ,
252+ "START_DATE" : "2024-01-01" ,
253+ "END_DATE" : "2024-01-01" ,
254+ },
255+ clear = True ,
256+ )
257+ def test_get_env_vars_equal_start_and_end_date (self ):
258+ """Test that an error is raised when START_DATE equals END_DATE"""
259+ with self .assertRaises (ValueError ) as cm :
260+ env .get_env_vars ()
261+ the_exception = cm .exception
262+ self .assertEqual (
263+ str (the_exception ),
264+ "END_DATE ('2024-01-01') must be after START_DATE ('2024-01-01')" ,
265+ )
266+
267+ @patch .dict (
268+ os .environ ,
269+ {
270+ "ORGANIZATION" : "org" ,
271+ "REPOSITORY" : "repo" ,
272+ "GH_TOKEN" : "token" ,
273+ "START_DATE" : "2024-01-01" ,
274+ "END_DATE" : "2025-01-01" ,
275+ },
276+ clear = True ,
277+ )
278+ def test_get_env_vars_valid_date_range (self ):
279+ """Test that valid date range (START_DATE before END_DATE) is accepted"""
280+ (
281+ _organization ,
282+ _repository_list ,
283+ _gh_app_id ,
284+ _gh_app_installation_id ,
285+ _gh_app_private_key ,
286+ _gh_app_enterprise_only ,
287+ _token ,
288+ _ghe ,
289+ start_date ,
290+ end_date ,
291+ _sponsor_info ,
292+ _link_to_profile ,
293+ ) = env .get_env_vars ()
294+ self .assertEqual (start_date , "2024-01-01" )
295+ self .assertEqual (end_date , "2025-01-01" )
296+
225297
226298if __name__ == "__main__" :
227299 unittest .main ()
0 commit comments