@@ -18,14 +18,8 @@ def setUp(self):
1818 Setup common test data and mocks.
1919 """
2020 self .issue = MagicMock ()
21- self .issue .issue .events .return_value = [
22- MagicMock (
23- event = "created_at" , created_at = datetime (2021 , 1 , 1 , tzinfo = pytz .utc )
24- ),
25- MagicMock (
26- event = "other_event" , created_at = datetime (2021 , 1 , 2 , tzinfo = pytz .utc )
27- ),
28- ]
21+ self .issue .issue .created_at = datetime (2021 , 1 , 1 , tzinfo = pytz .utc )
22+ self .issue .issue .state = "open"
2923
3024 def test_time_in_draft_with_ready_for_review (self ):
3125 """
@@ -38,7 +32,7 @@ def test_time_in_draft_with_ready_for_review(self):
3832
3933 def test_time_in_draft_without_ready_for_review (self ):
4034 """
41- Test measure_time_in_draft when ready_for_review_at is not provided.
35+ Test measure_time_in_draft when ready_for_review_at is not provided and issue is still open .
4236 """
4337 now = datetime (2021 , 1 , 4 , tzinfo = pytz .utc )
4438 with unittest .mock .patch ("time_in_draft.datetime" ) as mock_datetime :
@@ -47,13 +41,15 @@ def test_time_in_draft_without_ready_for_review(self):
4741 expected = timedelta (days = 3 )
4842 self .assertEqual (result , expected , "The time in draft should be 3 days." )
4943
50- def test_time_in_draft_with_no_events (self ):
44+ def test_time_in_draft_without_ready_for_review_and_closed (self ):
5145 """
52- Test measure_time_in_draft when there are no events .
46+ Test measure_time_in_draft when ready_for_review_at is not provided and issue is closed .
5347 """
54- self .issue .issue .events . return_value = []
48+ self .issue .issue .state = "closed"
5549 result = measure_time_in_draft (self .issue , None )
56- self .assertIsNone (result , "The result should be None when there are no events." )
50+ self .assertIsNone (
51+ result , "The result should be None when draft was never used."
52+ )
5753
5854
5955class TestGetStatsTimeInDraft (unittest .TestCase ):
0 commit comments