@@ -57,7 +57,7 @@ async def test_save_files_with_display_name(self):
5757 invocation_context = self .mock_context , user_message = user_message
5858 )
5959
60- # Verify artifact was saved with correct filename
60+ # Verify artifact was saved with correct filename (session-scoped by default)
6161 self .mock_context .artifact_service .save_artifact .assert_called_once_with (
6262 app_name = "test_app" ,
6363 user_id = "test_user" ,
@@ -66,7 +66,7 @@ async def test_save_files_with_display_name(self):
6666 artifact = original_part ,
6767 )
6868
69- # Verify message was modified with placeholder
69+ # Verify message was modified with placeholder (clean name)
7070 assert result .parts [0 ].text == '[Uploaded Artifact: "test_document.pdf"]'
7171
7272 @pytest .mark .asyncio
@@ -85,7 +85,7 @@ async def test_save_files_without_display_name(self):
8585 invocation_context = self .mock_context , user_message = user_message
8686 )
8787
88- # Verify artifact was saved with generated filename
88+ # Verify artifact was saved with generated filename (session-scoped by default)
8989 expected_filename = "artifact_test_invocation_123_0"
9090 self .mock_context .artifact_service .save_artifact .assert_called_once_with (
9191 app_name = "test_app" ,
@@ -95,8 +95,12 @@ async def test_save_files_without_display_name(self):
9595 artifact = original_part ,
9696 )
9797
98- # Verify message was modified with generated filename
99- assert result .parts [0 ].text == f'[Uploaded Artifact: "{ expected_filename } "]'
98+ # Verify message was modified with generated filename (clean name)
99+ generated_display_name = "artifact_test_invocation_123_0"
100+ assert (
101+ result .parts [0 ].text
102+ == f'[Uploaded Artifact: "{ generated_display_name } "]'
103+ )
100104
101105 @pytest .mark .asyncio
102106 async def test_multiple_files_in_message (self ):
@@ -138,7 +142,7 @@ async def test_multiple_files_in_message(self):
138142 )
139143 assert second_call [1 ]["filename" ] == "file2.jpg"
140144
141- # Verify message parts were modified correctly
145+ # Verify message parts were modified correctly (clean names)
142146 assert result .parts [0 ].text == '[Uploaded Artifact: "file1.txt"]'
143147 assert result .parts [1 ].text == "Some text between files" # Unchanged
144148 assert result .parts [2 ].text == '[Uploaded Artifact: "file2.jpg"]'
@@ -174,9 +178,8 @@ async def test_no_parts_in_message(self):
174178 invocation_context = self .mock_context , user_message = user_message
175179 )
176180
177- # Should return original message unchanged
178- assert result == user_message
179- assert result .parts == []
181+ # Should return None to proceed with original message
182+ assert result is None
180183
181184 # Should not try to save any artifacts
182185 self .mock_context .artifact_service .save_artifact .assert_not_called ()
@@ -193,10 +196,8 @@ async def test_parts_without_inline_data(self):
193196 invocation_context = self .mock_context , user_message = user_message
194197 )
195198
196- # Should return original message unchanged
197- assert result == user_message
198- assert result .parts [0 ].text == "Hello world"
199- assert result .parts [1 ].text == "No files here"
199+ # Should return None to proceed with original message
200+ assert result is None
200201
201202 # Should not try to save any artifacts
202203 self .mock_context .artifact_service .save_artifact .assert_not_called ()
@@ -221,9 +222,8 @@ async def test_save_artifact_failure(self):
221222 invocation_context = self .mock_context , user_message = user_message
222223 )
223224
224- # Should preserve original part when saving fails
225- assert result .parts [0 ] == original_part
226- assert result .parts [0 ].inline_data == inline_data
225+ # Should return None when saving fails (no modifications made)
226+ assert result is None
227227
228228 @pytest .mark .asyncio
229229 async def test_mixed_success_and_failure (self ):
@@ -264,7 +264,7 @@ def mock_save_artifact(*_args, **_kwargs):
264264 invocation_context = self .mock_context , user_message = user_message
265265 )
266266
267- # First file should be replaced with placeholder
267+ # First file should be replaced with placeholder (clean name)
268268 assert result .parts [0 ].text == '[Uploaded Artifact: "success.pdf"]'
269269
270270 # Second file should remain unchanged due to failure
@@ -287,7 +287,7 @@ async def test_placeholder_text_format(self):
287287 invocation_context = self .mock_context , user_message = user_message
288288 )
289289
290- # Verify exact format of placeholder text
290+ # Verify exact format of placeholder text (clean name)
291291 expected_text = '[Uploaded Artifact: "test file with spaces.docx"]'
292292 assert result .parts [0 ].text == expected_text
293293
0 commit comments