@@ -265,6 +265,78 @@ def test_get_env_vars_auth_with_github_app_installation_missing_inputs(self):
265265 "GH_APP_ID set and GH_APP_INSTALLATION_ID or GH_APP_PRIVATE_KEY variable not set" ,
266266 )
267267
268+ @patch .dict (
269+ os .environ ,
270+ {
271+ "ORGANIZATION" : "org" ,
272+ "REPOSITORY" : "repo" ,
273+ "GH_TOKEN" : "token" ,
274+ "START_DATE" : "2025-01-01" ,
275+ "END_DATE" : "2024-01-01" ,
276+ },
277+ clear = True ,
278+ )
279+ def test_get_env_vars_end_date_before_start_date (self ):
280+ """Test that an error is raised when END_DATE is before START_DATE"""
281+ with self .assertRaises (ValueError ) as cm :
282+ env .get_env_vars ()
283+ the_exception = cm .exception
284+ self .assertEqual (
285+ str (the_exception ),
286+ "END_DATE ('2024-01-01') must be after START_DATE ('2025-01-01')" ,
287+ )
288+
289+ @patch .dict (
290+ os .environ ,
291+ {
292+ "ORGANIZATION" : "org" ,
293+ "REPOSITORY" : "repo" ,
294+ "GH_TOKEN" : "token" ,
295+ "START_DATE" : "2024-01-01" ,
296+ "END_DATE" : "2024-01-01" ,
297+ },
298+ clear = True ,
299+ )
300+ def test_get_env_vars_equal_start_and_end_date (self ):
301+ """Test that an error is raised when START_DATE equals END_DATE"""
302+ with self .assertRaises (ValueError ) as cm :
303+ env .get_env_vars ()
304+ the_exception = cm .exception
305+ self .assertEqual (
306+ str (the_exception ),
307+ "END_DATE ('2024-01-01') must be after START_DATE ('2024-01-01')" ,
308+ )
309+
310+ @patch .dict (
311+ os .environ ,
312+ {
313+ "ORGANIZATION" : "org" ,
314+ "REPOSITORY" : "repo" ,
315+ "GH_TOKEN" : "token" ,
316+ "START_DATE" : "2024-01-01" ,
317+ "END_DATE" : "2025-01-01" ,
318+ },
319+ clear = True ,
320+ )
321+ def test_get_env_vars_valid_date_range (self ):
322+ """Test that valid date range (START_DATE before END_DATE) is accepted"""
323+ (
324+ _organization ,
325+ _repository_list ,
326+ _gh_app_id ,
327+ _gh_app_installation_id ,
328+ _gh_app_private_key ,
329+ _gh_app_enterprise_only ,
330+ _token ,
331+ _ghe ,
332+ start_date ,
333+ end_date ,
334+ _sponsor_info ,
335+ _link_to_profile ,
336+ ) = env .get_env_vars ()
337+ self .assertEqual (start_date , "2024-01-01" )
338+ self .assertEqual (end_date , "2025-01-01" )
339+
268340
269341if __name__ == "__main__" :
270342 unittest .main ()
0 commit comments