@@ -138,6 +138,33 @@ async def test_register(self, mock_client: AsyncMock) -> None:
138138 assert "test-wf" in call_kwargs ["supported_workflow_types" ]
139139 assert call_kwargs ["workflow_definition_fingerprints" ]["test-wf" ].startswith ("sha256:" )
140140 assert "test-act" in call_kwargs ["supported_activity_types" ]
141+ assert call_kwargs ["max_concurrent_workflow_tasks" ] == 10
142+ assert call_kwargs ["max_concurrent_activity_tasks" ] == 10
143+
144+ @pytest .mark .asyncio
145+ async def test_register_advertises_custom_concurrency_limits (self , mock_client : AsyncMock ) -> None :
146+ worker = Worker (
147+ mock_client ,
148+ task_queue = "q1" ,
149+ workflows = [TestWorkflow ],
150+ activities = [echo_activity ],
151+ worker_id = "w-capacity" ,
152+ max_concurrent_workflow_tasks = 3 ,
153+ max_concurrent_activity_tasks = 7 ,
154+ )
155+ await worker ._register ()
156+ call_kwargs = mock_client .register_worker .call_args .kwargs
157+ assert call_kwargs ["max_concurrent_workflow_tasks" ] == 3
158+ assert call_kwargs ["max_concurrent_activity_tasks" ] == 7
159+
160+ def test_constructor_rejects_non_positive_concurrency_limits (
161+ self , mock_client : AsyncMock
162+ ) -> None :
163+ with pytest .raises (ValueError , match = "max_concurrent_workflow_tasks" ):
164+ Worker (mock_client , task_queue = "q1" , max_concurrent_workflow_tasks = 0 )
165+
166+ with pytest .raises (ValueError , match = "max_concurrent_activity_tasks" ):
167+ Worker (mock_client , task_queue = "q1" , max_concurrent_activity_tasks = 0 )
141168
142169 def test_constructor_rejects_changed_workflow_definition_for_same_worker_id (
143170 self , mock_client : AsyncMock
0 commit comments