@@ -108,8 +108,8 @@ def test_get_env_vars(self):
108108 """Test that the function correctly retrieves the environment variables."""
109109
110110 # Call the function and check the result
111- search_query = get_env_vars ().search_query
112- gh_token = get_env_vars ().gh_token
111+ search_query = get_env_vars (test = True ).search_query
112+ gh_token = get_env_vars (test = True ).gh_token
113113 gh_token_expected_result = "test_token"
114114 search_query_expected_result = "is:issue is:open repo:user/repo"
115115 self .assertEqual (gh_token , gh_token_expected_result )
@@ -238,6 +238,10 @@ def test_main_no_issues_found(
238238class TestGetPerIssueMetrics (unittest .TestCase ):
239239 """Test suite for the get_per_issue_metrics function."""
240240
241+ @patch .dict (
242+ os .environ ,
243+ {"GH_TOKEN" : "test_token" , "SEARCH_QUERY" : "is:issue is:open repo:user/repo" },
244+ )
241245 def test_get_per_issue_metrics (self ):
242246 """Test that the function correctly calculates the metrics for a list of GitHub issues."""
243247 # Create mock data
@@ -286,7 +290,7 @@ def test_get_per_issue_metrics(self):
286290 result_issues_with_metrics ,
287291 result_num_issues_open ,
288292 result_num_issues_closed ,
289- ) = get_per_issue_metrics (issues )
293+ ) = get_per_issue_metrics (issues , env_vars = get_env_vars ( test = True ) )
290294 expected_issues_with_metrics = [
291295 IssueWithMetrics (
292296 "Issue 1" ,
@@ -364,14 +368,20 @@ def setUp(self):
364368 "closedAt" : "2023-01-07T00:00:00Z" ,
365369 }
366370
371+ @patch .dict (
372+ os .environ ,
373+ {"GH_TOKEN" : "test_token" , "SEARCH_QUERY" : "is:issue is:open repo:user/repo" },
374+ )
367375 def test_get_per_issue_metrics_with_discussion (self ):
368376 """
369377 Test that the function correctly calculates
370378 the metrics for a list of GitHub issues with discussions.
371379 """
372380
373381 issues = [self .issue1 , self .issue2 ]
374- metrics = get_per_issue_metrics (issues , discussions = True )
382+ metrics = get_per_issue_metrics (
383+ issues , discussions = True , env_vars = get_env_vars (test = True )
384+ )
375385
376386 # get_per_issue_metrics returns a tuple of
377387 # (issues_with_metrics, num_issues_open, num_issues_closed)
0 commit comments