@@ -189,43 +189,22 @@ def test_completed_task_invalid_artifact_type(self):
189189 )
190190
191191 def test_new_task_with_invalid_context_id (self ):
192- with pytest .raises (
193- ValueError ,
194- match = "Invalid context_id: 'not-a-uuid' is not a valid UUID." ,
195- ):
196- new_task (
197- Message (
198- role = Role .user ,
199- parts = [Part (root = TextPart (text = 'test message' ))],
200- message_id = str (uuid .uuid4 ()),
201- context_id = 'not-a-uuid' ,
202- )
203- )
204-
205- def test_new_task_with_empty_string_context_id (self ):
206- with pytest .raises (
207- ValueError , match = "Invalid context_id: '' is not a valid UUID."
208- ):
209- new_task (
210- Message (
211- role = Role .user ,
212- parts = [Part (root = TextPart (text = 'test message' ))],
213- message_id = str (uuid .uuid4 ()),
214- context_id = '' ,
215- )
216- )
217-
218- def test_new_task_with_valid_context_id (self ):
219- valid_uuid = '123e4567-e89b-12d3-a456-426614174000'
220- task = new_task (
221- Message (
222- role = Role .user ,
223- parts = [Part (root = TextPart (text = 'test message' ))],
224- message_id = str (uuid .uuid4 ()),
225- context_id = valid_uuid ,
226- )
227- )
228- self .assertEqual (task .context_id , valid_uuid )
192+ """Test that new_task raises a ValueError for various invalid context_id formats."""
193+ invalid_ids = ["not-a-uuid" , "" ]
194+ for invalid_id in invalid_ids :
195+ with self .subTest (invalid_id = invalid_id ):
196+ with pytest .raises (
197+ ValueError ,
198+ match = f"Invalid context_id: '{ invalid_id } ' is not a valid UUID." ,
199+ ):
200+ new_task (
201+ Message (
202+ role = Role .user ,
203+ parts = [Part (root = TextPart (text = 'test message' ))],
204+ message_id = str (uuid .uuid4 ()),
205+ context_id = invalid_id ,
206+ )
207+ )
229208
230209
231210if __name__ == '__main__' :
0 commit comments