From 1379f900390fc035fd9241100228f14d3f90c916 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 00:01:18 +0000 Subject: [PATCH 1/5] Initial empty commit to create PR From 80f958f2ca2e555b5e272fa091ec5c94f4b4c3cf Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 00:02:31 +0000 Subject: [PATCH 2/5] Replace content of services/anthropic/test_remove_duplicate_get_remote_file_content_results.py [skip ci] --- ...plicate_get_remote_file_content_results.py | 351 +++++++++++++++++- 1 file changed, 348 insertions(+), 3 deletions(-) diff --git a/services/anthropic/test_remove_duplicate_get_remote_file_content_results.py b/services/anthropic/test_remove_duplicate_get_remote_file_content_results.py index 3fd61bca6..edb7990ae 100644 --- a/services/anthropic/test_remove_duplicate_get_remote_file_content_results.py +++ b/services/anthropic/test_remove_duplicate_get_remote_file_content_results.py @@ -5,9 +5,8 @@ # Local imports from config import UTF8 -from services.anthropic.remove_duplicate_get_remote_file_content_results import ( - remove_duplicate_get_remote_file_content_results, -) +from services.anthropic.remove_duplicate_get_remote_file_content_results import \ + remove_duplicate_get_remote_file_content_results def test_remove_duplicate_get_remote_file_content_results_only(): @@ -190,3 +189,349 @@ def get(self, key, default=None): result = remove_duplicate_get_remote_file_content_results(messages) # Should return original messages unchanged when exception occurs assert result == messages + + +def test_empty_messages_list(): + # Test with empty list - covers line 11 + messages = [] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == [] + + +def test_none_messages(): + # Test with None - covers line 11 + messages = None + result = remove_duplicate_get_remote_file_content_results(messages) + assert result is None + + +def test_non_dict_item_in_content(): + # Test with non-dict item in content list - covers lines 26, 54, 55 + messages = [ + { + "role": "user", + "content": [ + "string item", # Not a dict + {"type": "text", "text": "some text"}, # Dict but not tool_result + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_tool_result_without_opened_file_prefix(): + # Test tool_result that doesn't start with "Opened file: '" - covers lines 36, 66, 67 + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Some other tool result", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_opened_file_without_required_suffix(): + # Test file content without required suffix - covers lines 36, 66, 67 + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'test.py' but missing required suffix", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_invalid_filename_extraction(): + # Test with invalid filename extraction - covers lines 41, 72, 73 + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: with line numbers for your information.", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_filename_with_no_closing_quote(): + # Test filename extraction with no closing quote - covers lines 41, 72, 73 + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'test.py with line numbers for your information.", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_multiple_occurrences_suffix(): + # Test with "and found multiple occurrences of" suffix + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'test.py' and found multiple occurrences of pattern.\n\nOld content", + } + ], + }, + {"role": "assistant", "content": "OK"}, + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id2", + "content": "Opened file: 'test.py' and found multiple occurrences of pattern.\n\nNew content", + } + ], + }, + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result[0]["content"][0]["content"] == "[Outdated 'test.py' content removed]" + assert "New content" in result[2]["content"][0]["content"] + + +def test_message_with_non_list_content(): + # Test message with content that is not a list + messages = [ + {"role": "user", "content": "string content"}, + {"role": "assistant", "content": "response"}, + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_message_without_role(): + # Test message without role field + messages = [ + {"content": "some content"}, + {"role": "user", "content": "Hello"}, + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_message_with_assistant_role(): + # Test that assistant messages are skipped + messages = [ + { + "role": "assistant", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'test.py' with line numbers for your information.\n\nContent", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_multiple_files_deduplication(): + # Test deduplication of multiple different files + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'file1.py' with line numbers for your information.\n\nFile1 v1", + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id2", + "content": "Opened file: 'file2.py' with line numbers for your information.\n\nFile2 v1", + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id3", + "content": "Opened file: 'file1.py' with line numbers for your information.\n\nFile1 v2", + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id4", + "content": "Opened file: 'file2.py' with line numbers for your information.\n\nFile2 v2", + } + ], + }, + ] + result = remove_duplicate_get_remote_file_content_results(messages) + # First occurrences should be replaced + assert result[0]["content"][0]["content"] == "[Outdated 'file1.py' content removed]" + assert result[1]["content"][0]["content"] == "[Outdated 'file2.py' content removed]" + # Latest occurrences should be kept + assert "File1 v2" in result[2]["content"][0]["content"] + assert "File2 v2" in result[3]["content"][0]["content"] + + +def test_mixed_content_types_in_message(): + # Test message with mixed content types + messages = [ + { + "role": "user", + "content": [ + {"type": "text", "text": "Some text"}, + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'test.py' with line numbers for your information.\n\nOld content", + }, + {"type": "image", "source": "image_data"}, + ], + }, + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id2", + "content": "Opened file: 'test.py' with line numbers for your information.\n\nNew content", + } + ], + }, + ] + result = remove_duplicate_get_remote_file_content_results(messages) + # First message should have file content replaced but other items preserved + assert len(result[0]["content"]) == 3 + assert result[0]["content"][0]["type"] == "text" + assert result[0]["content"][1]["content"] == "[Outdated 'test.py' content removed]" + assert result[0]["content"][2]["type"] == "image" + # Second message should be unchanged + assert "New content" in result[1]["content"][0]["content"] + + +def test_same_file_single_occurrence(): + # Test file that appears only once (should not be replaced) + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'unique.py' with line numbers for your information.\n\nContent", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + # Should remain unchanged since there's no duplicate + assert "Content" in result[0]["content"][0]["content"] + assert "[Outdated" not in result[0]["content"][0]["content"] + + +def test_tool_result_with_empty_content(): + # Test tool_result with empty content + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_tool_result_without_content_key(): + # Test tool_result without content key + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + } + ], + } + ] + result = remove_duplicate_get_remote_file_content_results(messages) + assert result == messages + + +def test_preserves_original_messages(): + # Test that original messages are not modified + messages = [ + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id1", + "content": "Opened file: 'test.py' with line numbers for your information.\n\nOld", + } + ], + }, + { + "role": "user", + "content": [ + { + "type": "tool_result", + "tool_use_id": "id2", + "content": "Opened file: 'test.py' with line numbers for your information.\n\nNew", + } + ], + }, + ] + original_copy = deepcopy(messages) + result = remove_duplicate_get_remote_file_content_results(messages) + + # Original should be unchanged + assert messages == original_copy + # Result should be different + assert result != messages From 4ab362787aa141db6885f0bd9f02de87de126464 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 00:04:19 +0000 Subject: [PATCH 3/5] Empty commit to trigger final tests From 16a20c6eb0ef3d6e82f78724aea6aaa8bde36bc9 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:20:15 +0000 Subject: [PATCH 4/5] Update services/webhook/test_review_run_handler.py [skip ci] --- services/webhook/test_review_run_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/services/webhook/test_review_run_handler.py b/services/webhook/test_review_run_handler.py index ca1fa988e..408a3520f 100644 --- a/services/webhook/test_review_run_handler.py +++ b/services/webhook/test_review_run_handler.py @@ -17,6 +17,7 @@ def mock_review_comment_payload(): "subject_type": "line", "line": 42, "side": "RIGHT", + "user": {"login": "test-reviewer", "type": "User"}, "body": "This function could be optimized. Consider using a more efficient algorithm.", }, "pull_request": { From 0e25370db8b888dec002c51eb41369561baed812 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:20:43 +0000 Subject: [PATCH 5/5] Empty commit to trigger final tests