Skip to content

Commit

Permalink
Fix lint errors and remove obsolete code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Adams authored and Jake Adams committed Mar 5, 2025
1 parent fb05049 commit 7047248
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
2 changes: 2 additions & 0 deletions issue_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def get_per_issue_metrics(

return issues_with_metrics, num_issues_open, num_issues_closed


def evaluate_markdown_file_size(output_file: str) -> None:
file_name_without_extension = Path(output_file).stem
max_char_count = 65535
Expand All @@ -180,6 +181,7 @@ def evaluate_markdown_file_size(output_file: str) -> None:
See https://github.com/github/issue-metrics/blob/main/docs/dealing-with-large-issue-metrics.md"
)


def main(): # pragma: no cover
"""Run the issue-metrics script.
Expand Down
37 changes: 13 additions & 24 deletions test_issue_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def test_get_per_issue_metrics_with_hide_envs(self):
"HIDE_TIME_TO_ANSWER": "false",
"HIDE_TIME_TO_CLOSE": "false",
"HIDE_TIME_TO_FIRST_RESPONSE": "false",
"OUTPUT_FILE": "test_issue_metrics.md"
},
)
def test_get_per_issue_metrics_without_hide_envs(self):
Expand Down Expand Up @@ -483,16 +482,10 @@ def test_get_per_issue_metrics_with_discussion_with_hide_envs(self):
class TestEvaluateMarkdownFileSize(unittest.TestCase):
"""Test suite for the evaluate_markdown_file_size function."""

@patch.dict(
os.environ,
{
"GH_TOKEN": "test_token",
"SEARCH_QUERY": "is:issue is:open repo:user/repo",
"OUTPUT_FILE": "test_issue_metrics.md"
}
)
@patch("issue_metrics.markdown_too_large_for_issue_body")
def test_markdown_too_large_for_issue_body_called_with_output_file(self, mock_evaluate):
def test_markdown_too_large_for_issue_body_called_with_output_file(
self, mock_evaluate
):
"""
Test that the function uses the output_file.
"""
Expand All @@ -501,19 +494,13 @@ def test_markdown_too_large_for_issue_body_called_with_output_file(self, mock_ev

mock_evaluate.assert_called_with("test_issue_metrics.md", 65535)

@patch.dict(
os.environ,
{
"GH_TOKEN": "test_token",
"SEARCH_QUERY": "is:issue is:open repo:user/repo",
"OUTPUT_FILE": "test_issue_metrics.md"
}
)
@patch("issue_metrics.print")
@patch("shutil.move")
@patch("issue_metrics.split_markdown_file")
@patch("issue_metrics.markdown_too_large_for_issue_body")
def test_split_markdown_file_when_file_size_too_large(self, mock_evaluate, mock_split, mock_move, mock_print):
def test_split_markdown_file_when_file_size_too_large(
self, mock_evaluate, mock_split, mock_move, mock_print
):
"""
Test that the function is called with the output_file
environment variable.
Expand All @@ -522,16 +509,18 @@ def test_split_markdown_file_when_file_size_too_large(self, mock_evaluate, mock_
evaluate_markdown_file_size("test_issue_metrics.md")

mock_split.assert_called_with("test_issue_metrics.md", 65535)
mock_move.assert_has_calls([
call("test_issue_metrics.md", "test_issue_metrics_full.md"),
call("test_issue_metrics_0.md", "test_issue_metrics.md")
])
mock_move.assert_has_calls(
[
call("test_issue_metrics.md", "test_issue_metrics_full.md"),
call("test_issue_metrics_0.md", "test_issue_metrics.md"),
]
)
mock_print.assert_called_with(
"Issue metrics markdown file is too large for GitHub issue body and has been \
split into multiple files. ie. test_issue_metrics.md, test_issue_metrics_1.md, etc. \
The full file is saved as test_issue_metrics_full.md\n\
See https://github.com/github/issue-metrics/blob/main/docs/dealing-with-large-issue-metrics.md"
)
)


if __name__ == "__main__":
Expand Down

0 comments on commit 7047248

Please sign in to comment.