@@ -748,27 +748,14 @@ async def test_post_500_resume(binding_string):
748748
749749@pytest .mark .asyncio
750750async def test_restart_with_new_instance_id (binding_string ):
751- """Test restart creates a new instance with a new ID by default."""
752- orchestrator_name = "MyOrchestrator"
753- original_input = {"key" : "value" }
751+ """Test restart calls the HTTP restart endpoint with restartWithNewInstanceId=true."""
754752 new_instance_id = "new-instance-id-1234"
755753
756- get_mock = MockRequest (
757- expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } ?showInput=True" ,
758- response = [200 , dict (
759- name = orchestrator_name ,
760- instanceId = TEST_INSTANCE_ID ,
761- createdTime = TEST_CREATED_TIME ,
762- lastUpdatedTime = TEST_LAST_UPDATED_TIME ,
763- runtimeStatus = "Completed" ,
764- input = original_input )])
765-
766754 post_mock = MockRequest (
767- expected_url = f"{ RPC_BASE_URL } orchestrators/ { orchestrator_name } " ,
768- response = [202 , { "id" : new_instance_id } ])
755+ expected_url = f"{ RPC_BASE_URL } instances/ { TEST_INSTANCE_ID } /restart?restartWithNewInstanceId=true " ,
756+ response = [202 , new_instance_id ])
769757
770758 client = DurableOrchestrationClient (binding_string )
771- client ._get_async_request = get_mock .get
772759 client ._post_async_request = post_mock .post
773760
774761 result = await client .restart (TEST_INSTANCE_ID )
@@ -777,26 +764,12 @@ async def test_restart_with_new_instance_id(binding_string):
777764
778765@pytest .mark .asyncio
779766async def test_restart_with_same_instance_id (binding_string ):
780- """Test restart reuses the original instance ID when restartWithNewInstanceId is False."""
781- orchestrator_name = "MyOrchestrator"
782- original_input = {"key" : "value" }
783-
784- get_mock = MockRequest (
785- expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } ?showInput=True" ,
786- response = [200 , dict (
787- name = orchestrator_name ,
788- instanceId = TEST_INSTANCE_ID ,
789- createdTime = TEST_CREATED_TIME ,
790- lastUpdatedTime = TEST_LAST_UPDATED_TIME ,
791- runtimeStatus = "Completed" ,
792- input = original_input )])
793-
767+ """Test restart calls the HTTP restart endpoint with restartWithNewInstanceId=false."""
794768 post_mock = MockRequest (
795- expected_url = f"{ RPC_BASE_URL } orchestrators/ { orchestrator_name } / { TEST_INSTANCE_ID } " ,
796- response = [202 , { "id" : TEST_INSTANCE_ID } ])
769+ expected_url = f"{ RPC_BASE_URL } instances/ { TEST_INSTANCE_ID } /restart?restartWithNewInstanceId=false " ,
770+ response = [202 , TEST_INSTANCE_ID ])
797771
798772 client = DurableOrchestrationClient (binding_string )
799- client ._get_async_request = get_mock .get
800773 client ._post_async_request = post_mock .post
801774
802775 result = await client .restart (TEST_INSTANCE_ID , restart_with_new_instance_id = False )
@@ -806,16 +779,16 @@ async def test_restart_with_same_instance_id(binding_string):
806779@pytest .mark .asyncio
807780async def test_restart_instance_not_found (binding_string ):
808781 """Test restart raises exception when instance is not found."""
809- get_mock = MockRequest (
810- expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } ?showInput=True " ,
811- response = [404 , dict ( createdTime = None , lastUpdatedTime = None ) ])
782+ post_mock = MockRequest (
783+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /restart?restartWithNewInstanceId=true " ,
784+ response = [404 , None ])
812785
813786 client = DurableOrchestrationClient (binding_string )
814- client ._get_async_request = get_mock . get
787+ client ._post_async_request = post_mock . post
815788
816789 with pytest .raises (Exception ) as ex :
817790 await client .restart (TEST_INSTANCE_ID )
818- assert f"instanceId { TEST_INSTANCE_ID } was not found" in str (ex .value )
791+ assert f"No instance with ID ' { TEST_INSTANCE_ID } ' found. " in str (ex .value )
819792# Tests for function_invocation_id parameter
820793def test_client_stores_function_invocation_id (binding_string ):
821794 """Test that the client stores the function_invocation_id parameter."""
0 commit comments