@@ -86,6 +86,7 @@ def _make_storage_with_mock_repo():
8686 mock_repo = MagicMock ()
8787 mock_repo .set_miner .return_value = 1
8888 mock_repo .store_pull_requests_bulk .return_value = 0 # actual count irrelevant
89+ mock_repo .refresh_stale_pr_states .return_value = 0
8990 mock_repo .store_issues_bulk .return_value = 0
9091 mock_repo .store_file_changes_bulk .return_value = 0
9192 mock_repo .set_miner_evaluation .return_value = True
@@ -173,12 +174,17 @@ def test_stale_closed_prs_are_stored_separately(self):
173174
174175 storage .store_evaluation (eval_ )
175176
176- stale_call = mock_repo .store_pull_requests_bulk .call_args_list [3 ]
177- stale_arg = stale_call .args [0 ]
177+ # Stale PRs must go through refresh_stale_pr_states (targeted UPDATE), not the
178+ # full-column UPSERT, so previously-scored rows are not overwritten with defaults.
179+ mock_repo .refresh_stale_pr_states .assert_called_once ()
180+ stale_arg = mock_repo .refresh_stale_pr_states .call_args .args [0 ]
178181 assert len (stale_arg ) == 1
179182 assert stale_arg [0 ].number == 7
180183 assert stale_arg [0 ].pr_state == PRState .CLOSED
181184 assert eval_ .total_closed_prs == 0
185+ # Verify the stale PR did not leak into store_pull_requests_bulk
186+ for call in mock_repo .store_pull_requests_bulk .call_args_list :
187+ assert not any (pr .number == 7 for pr in call .args [0 ])
182188
183189
184190def test_cleanup_stale_called_with_commit_false ():
0 commit comments