|
5 | 5 | from sentry.seer.autofix.autofix_agent import AutofixStep |
6 | 6 | from sentry.seer.autofix.constants import AutofixReferrer, AutofixStatus |
7 | 7 | from sentry.seer.autofix.utils import AutofixState, AutofixStoppingPoint, CodebaseState |
| 8 | +from sentry.seer.models.seer_api_models import SeerPermissionError |
8 | 9 | from sentry.testutils.cases import APITestCase, SnubaTestCase |
9 | 10 | from sentry.testutils.helpers.datetime import before_now |
10 | 11 | from sentry.testutils.helpers.features import with_feature |
@@ -1030,6 +1031,27 @@ def test_open_pr_no_run_id(self): |
1030 | 1031 | assert response.status_code == 400, f"Failed for {flag}: {response.data}" |
1031 | 1032 | assert response.data["detail"] == "run_id is required for open_pr" |
1032 | 1033 |
|
| 1034 | + @patch( |
| 1035 | + "sentry.seer.endpoints.group_ai_autofix.trigger_push_changes", |
| 1036 | + side_effect=SeerPermissionError("Unknown run id for group"), |
| 1037 | + ) |
| 1038 | + def test_open_pr_permission_error(self, mock_trigger_push_changes): |
| 1039 | + self.login_as(user=self.user) |
| 1040 | + |
| 1041 | + for flag in EXPLORER_FLAGS: |
| 1042 | + group = self.create_group() |
| 1043 | + with self.feature(flag): |
| 1044 | + response = self.client.post( |
| 1045 | + self._get_url(group.id, mode="explorer"), |
| 1046 | + data={ |
| 1047 | + "step": "open_pr", |
| 1048 | + "run_id": 123, |
| 1049 | + }, |
| 1050 | + format="json", |
| 1051 | + ) |
| 1052 | + |
| 1053 | + assert response.status_code == 404, f"Failed for {flag}: {response.data}" |
| 1054 | + |
1033 | 1055 |
|
1034 | 1056 | @with_feature("organizations:gen-ai-features") |
1035 | 1057 | @with_feature("organizations:seer-explorer") |
|
0 commit comments