Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webhook_server/libs/handlers/issue_comment_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ async def user_commands(
remove=remove,
reviewed_user=reviewed_user,
)
if _command == APPROVE_STR:
if _command == APPROVE_STR and not remove:
task = asyncio.create_task(
call_test_oracle(
github_webhook=self.github_webhook,
Expand Down
26 changes: 26 additions & 0 deletions webhook_server/tests/test_issue_comment_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,3 +1485,29 @@ async def test_approve_command_calls_test_oracle(self, issue_comment_handler: Is
)
mock_create_task.assert_called_once()
assert asyncio.iscoroutine(mock_create_task.call_args.args[0])

@pytest.mark.asyncio
async def test_approve_cancel_does_not_call_test_oracle(self, issue_comment_handler: IssueCommentHandler) -> None:
"""Test that /approve cancel does NOT fire call_test_oracle."""
mock_pull_request = Mock()
mock_pull_request.draft = False

with patch("asyncio.to_thread", new_callable=AsyncMock, side_effect=lambda f, *a, **k: f(*a, **k)):
with patch.object(issue_comment_handler, "create_comment_reaction", new_callable=AsyncMock):
with patch.object(
issue_comment_handler.labels_handler, "label_by_user_comment", new_callable=AsyncMock
):
with patch(
"webhook_server.libs.handlers.issue_comment_handler.call_test_oracle",
new_callable=AsyncMock,
) as mock_oracle:
with patch("asyncio.create_task") as mock_create_task:
await issue_comment_handler.user_commands(
pull_request=mock_pull_request,
command=f"{APPROVE_STR} cancel",
reviewed_user="test-user",
issue_comment_id=456,
is_draft=False,
)
mock_oracle.assert_not_called()
mock_create_task.assert_not_called()