From 2f684840d106121534a060be42188f213cf02f0b Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Wed, 23 Oct 2024 08:11:09 -0700 Subject: [PATCH] feat: Add time in draft to IssueWithMetrics class attributes and update failing tests that were using positional args Signed-off-by: Zack Koppert --- classes.py | 3 +++ test_labels.py | 8 +++++- test_markdown_writer.py | 56 ++++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/classes.py b/classes.py index e1e6684..7428d31 100644 --- a/classes.py +++ b/classes.py @@ -18,6 +18,7 @@ class IssueWithMetrics: time_to_close (timedelta, optional): The time it took to close the issue. time_to_answer (timedelta, optional): The time it took to answer the discussions in the issue. + time_in_draft (timedelta, optional): The time the PR was in draft state. label_metrics (dict, optional): A dictionary containing the label metrics mentor_activity (dict, optional): A dictionary containing active mentors @@ -33,6 +34,7 @@ def __init__( time_to_first_response=None, time_to_close=None, time_to_answer=None, + time_in_draft=None, labels_metrics=None, mentor_activity=None, ): @@ -42,5 +44,6 @@ def __init__( self.time_to_first_response = time_to_first_response self.time_to_close = time_to_close self.time_to_answer = time_to_answer + self.time_in_draft = time_in_draft self.label_metrics = labels_metrics self.mentor_activity = mentor_activity diff --git a/test_labels.py b/test_labels.py index e7e8b5f..2fb8212 100644 --- a/test_labels.py +++ b/test_labels.py @@ -101,7 +101,13 @@ def setUp(self): self.issues_with_metrics = MagicMock() self.issues_with_metrics = [ IssueWithMetrics( - "issue1", "url1", "alice", None, None, None, {"bug": timedelta(days=2)} + title="issue1", + html_url="url1", + author="alice", + time_to_first_response=None, + time_to_close=None, + time_to_answer=None, + labels_metrics={"bug": timedelta(days=2)}, ), ] diff --git a/test_markdown_writer.py b/test_markdown_writer.py index 3678d0b..8d69d35 100644 --- a/test_markdown_writer.py +++ b/test_markdown_writer.py @@ -37,22 +37,22 @@ def test_write_to_markdown(self): # Create mock data issues_with_metrics = [ IssueWithMetrics( - "Issue 1", - "https://github.com/user/repo/issues/1", - "alice", - timedelta(days=1), - timedelta(days=2), - timedelta(days=3), - {"bug": timedelta(days=1)}, + title="Issue 1", + html_url="https://github.com/user/repo/issues/1", + author="alice", + time_to_first_response=timedelta(days=1), + time_to_close=timedelta(days=2), + time_to_answer=timedelta(days=3), + labels_metrics={"bug": timedelta(days=1)}, ), IssueWithMetrics( - "Issue 2\r", - "https://github.com/user/repo/issues/2", - "bob", - timedelta(days=3), - timedelta(days=4), - timedelta(days=5), - {"bug": timedelta(days=2)}, + title="Issue 2\r", + html_url="https://github.com/user/repo/issues/2", + author="bob", + time_to_first_response=timedelta(days=3), + time_to_close=timedelta(days=4), + time_to_answer=timedelta(days=5), + labels_metrics={"bug": timedelta(days=2)}, ), ] time_to_first_response = { @@ -139,22 +139,22 @@ def test_write_to_markdown_with_vertical_bar_in_title(self): # Create mock data issues_with_metrics = [ IssueWithMetrics( - "Issue 1", - "https://github.com/user/repo/issues/1", - "alice", - timedelta(days=1), - timedelta(days=2), - timedelta(days=3), - {"bug": timedelta(days=1)}, + title="Issue 1", + html_url="https://github.com/user/repo/issues/1", + author="alice", + time_to_first_response=timedelta(days=1), + time_to_close=timedelta(days=2), + time_to_answer=timedelta(days=3), + labels_metrics={"bug": timedelta(days=1)}, ), IssueWithMetrics( - "feat| Issue 2", # title contains a vertical bar - "https://github.com/user/repo/issues/2", - "bob", - timedelta(days=3), - timedelta(days=4), - timedelta(days=5), - {"bug": timedelta(days=2)}, + title="feat| Issue 2", # title contains a vertical bar + html_url="https://github.com/user/repo/issues/2", + author="bob", + time_to_first_response=timedelta(days=3), + time_to_close=timedelta(days=4), + time_to_answer=timedelta(days=5), + labels_metrics={"bug": timedelta(days=2)}, ), ] average_time_to_first_response = {