From b2b952716428da53b22171163f37f59bc3659b14 Mon Sep 17 00:00:00 2001 From: "ievgenii.v" Date: Thu, 30 Oct 2025 16:46:53 +0200 Subject: [PATCH] feature: fix minor bugs, fix tests --- .../apps/repository/tests/test_ai_code_review.py | 3 +-- .../apps/repository/views/repo_pull_requests.py | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/rhodecode/apps/repository/tests/test_ai_code_review.py b/rhodecode/apps/repository/tests/test_ai_code_review.py index cb22192a..de6a9e2f 100644 --- a/rhodecode/apps/repository/tests/test_ai_code_review.py +++ b/rhodecode/apps/repository/tests/test_ai_code_review.py @@ -86,7 +86,6 @@ class TestAiCodeReview: assert response.status_code == 200 assert run_task_mock.call_count == 1 - assert len(existing_reviewers) == 1 - assert existing_reviewers[0].user_id == ai_user.user_id + assert ai_user.user_id in [u.user_id for u in existing_reviewers] assert len(success_message) == 1 assert success_message[0] == "AI code review has started. The review will be ready in about 1–3 minutes." diff --git a/rhodecode/apps/repository/views/repo_pull_requests.py b/rhodecode/apps/repository/views/repo_pull_requests.py index 87f4176e..e5548da4 100644 --- a/rhodecode/apps/repository/views/repo_pull_requests.py +++ b/rhodecode/apps/repository/views/repo_pull_requests.py @@ -1311,7 +1311,6 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView): ) self._try_start_ai_code_review(_, pull_request, add_existing_users=True) - self._set_ai_pr_state_pending(pull_request) return {"response": True, "redirect_url": redirect_url} @@ -1368,7 +1367,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView): ) ) - reviewers_data = [ + reviewers_data.append( ( ai_user.user_id, ["adds system ai user for review"], @@ -1376,7 +1375,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView): PullRequestReviewers.ROLE_REVIEWER, pull_request.reviewer_data ) - ] + ) PullRequestModel().update_reviewers( pull_request, reviewers_data, self._rhodecode_db_user @@ -1385,6 +1384,8 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView): Session().commit() run_task(tasks.start_ai_code_review, pull_request.pull_request_id) + self._set_ai_pr_state_pending(pull_request) + msg = _("AI code review has started. The review will be ready in about 1–3 minutes.") h.flash(msg, category="success") else: @@ -1439,10 +1440,7 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView): user_id = safe_int(member_data.get("user_id", -1)) if ai_user_id == user_id: - success = self._try_start_ai_code_review(_, pull_request) - if not success: - del members_[i] - + self._try_start_ai_code_review(_, pull_request) break self._update_reviewers(