File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ def __init__(
4141 initial_message: The `Message` that initiated the task, if any.
4242 Used when creating a new task object.
4343 """
44+ if task_id is not None and not (isinstance (task_id , str ) and task_id ):
45+ raise ValueError ('Task ID must be a non-empty string' )
46+
4447 self .task_id = task_id
4548 self .context_id = context_id
4649 self .task_store = task_store
Original file line number Diff line number Diff line change @@ -45,6 +45,20 @@ def task_manager(mock_task_store: AsyncMock) -> TaskManager:
4545 )
4646
4747
48+ @pytest .mark .parametrize ('invalid_task_id' , ['' , 123 ])
49+ def test_task_manager_invalid_task_id (
50+ mock_task_store : AsyncMock , invalid_task_id : Any
51+ ):
52+ """Test that TaskManager raises ValueError for an invalid task_id."""
53+ with pytest .raises (ValueError , match = 'Task ID must be a non-empty string' ):
54+ TaskManager (
55+ task_id = invalid_task_id ,
56+ context_id = 'test_context' ,
57+ task_store = mock_task_store ,
58+ initial_message = None ,
59+ )
60+
61+
4862@pytest .mark .asyncio
4963async def test_get_task_existing (
5064 task_manager : TaskManager , mock_task_store : AsyncMock
You can’t perform that action at this time.
0 commit comments