@@ -137,7 +137,15 @@ def test_create_check_status_response(binding_string):
137
137
"purgeHistoryDeleteUri" :
138
138
r"http://test_azure.net/runtime/webhooks/durabletask/instances/"
139
139
r"2e2568e7-a906-43bd-8364-c81733c5891e"
140
- r"?taskHub=TASK_HUB_NAME&connection=Storage&code=AUTH_CODE"
140
+ r"?taskHub=TASK_HUB_NAME&connection=Storage&code=AUTH_CODE" ,
141
+ "suspendPostUri" :
142
+ r"http://test_azure.net/runtime/webhooks/durabletask/instances/"
143
+ r"2e2568e7-a906-43bd-8364-c81733c5891e/suspend"
144
+ r"?reason={text}&taskHub=TASK_HUB_NAME&connection=Storage&code=AUTH_CODE" ,
145
+ "resumePostUri" :
146
+ r"http://test_azure.net/runtime/webhooks/durabletask/instances/"
147
+ r"2e2568e7-a906-43bd-8364-c81733c5891e/resume"
148
+ r"?reason={text}&taskHub=TASK_HUB_NAME&connection=Storage&code=AUTH_CODE"
141
149
}
142
150
for key , _ in http_management_payload .items ():
143
151
http_management_payload [key ] = replace_stand_in_bits (http_management_payload [key ])
@@ -610,3 +618,113 @@ async def test_rewind_with_no_rpc_endpoint(binding_string):
610
618
await client .rewind (INSTANCE_ID , REASON )
611
619
ex_message = str (ex .value )
612
620
assert ex_message == expected_exception_str
621
+
622
+ @pytest .mark .asyncio
623
+ async def test_post_202_suspend (binding_string ):
624
+ raw_reason = 'stuff and things'
625
+ reason = 'stuff%20and%20things'
626
+ mock_request = MockRequest (
627
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /suspend?reason={ reason } " ,
628
+ response = [202 , None ])
629
+ client = DurableOrchestrationClient (binding_string )
630
+ client ._post_async_request = mock_request .post
631
+
632
+ result = await client .suspend (TEST_INSTANCE_ID , raw_reason )
633
+ assert result is None
634
+
635
+
636
+ @pytest .mark .asyncio
637
+ async def test_post_410_suspend (binding_string ):
638
+ raw_reason = 'stuff and things'
639
+ reason = 'stuff%20and%20things'
640
+ mock_request = MockRequest (
641
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /suspend?reason={ reason } " ,
642
+ response = [410 , None ])
643
+ client = DurableOrchestrationClient (binding_string )
644
+ client ._post_async_request = mock_request .post
645
+
646
+ result = await client .suspend (TEST_INSTANCE_ID , raw_reason )
647
+ assert result is None
648
+
649
+
650
+ @pytest .mark .asyncio
651
+ async def test_post_404_suspend (binding_string ):
652
+ raw_reason = 'stuff and things'
653
+ reason = 'stuff%20and%20things'
654
+ mock_request = MockRequest (
655
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /suspend?reason={ reason } " ,
656
+ response = [404 , MESSAGE_404 ])
657
+ client = DurableOrchestrationClient (binding_string )
658
+ client ._post_async_request = mock_request .post
659
+
660
+ with pytest .raises (Exception ):
661
+ await client .suspend (TEST_INSTANCE_ID , raw_reason )
662
+
663
+
664
+ @pytest .mark .asyncio
665
+ async def test_post_500_suspend (binding_string ):
666
+ raw_reason = 'stuff and things'
667
+ reason = 'stuff%20and%20things'
668
+ mock_request = MockRequest (
669
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /suspend?reason={ reason } " ,
670
+ response = [500 , MESSAGE_500 ])
671
+ client = DurableOrchestrationClient (binding_string )
672
+ client ._post_async_request = mock_request .post
673
+
674
+ with pytest .raises (Exception ):
675
+ await client .suspend (TEST_INSTANCE_ID , raw_reason )
676
+
677
+ @pytest .mark .asyncio
678
+ async def test_post_202_resume (binding_string ):
679
+ raw_reason = 'stuff and things'
680
+ reason = 'stuff%20and%20things'
681
+ mock_request = MockRequest (
682
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /resume?reason={ reason } " ,
683
+ response = [202 , None ])
684
+ client = DurableOrchestrationClient (binding_string )
685
+ client ._post_async_request = mock_request .post
686
+
687
+ result = await client .resume (TEST_INSTANCE_ID , raw_reason )
688
+ assert result is None
689
+
690
+
691
+ @pytest .mark .asyncio
692
+ async def test_post_410_resume (binding_string ):
693
+ raw_reason = 'stuff and things'
694
+ reason = 'stuff%20and%20things'
695
+ mock_request = MockRequest (
696
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /resume?reason={ reason } " ,
697
+ response = [410 , None ])
698
+ client = DurableOrchestrationClient (binding_string )
699
+ client ._post_async_request = mock_request .post
700
+
701
+ result = await client .resume (TEST_INSTANCE_ID , raw_reason )
702
+ assert result is None
703
+
704
+
705
+ @pytest .mark .asyncio
706
+ async def test_post_404_resume (binding_string ):
707
+ raw_reason = 'stuff and things'
708
+ reason = 'stuff%20and%20things'
709
+ mock_request = MockRequest (
710
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /resume?reason={ reason } " ,
711
+ response = [404 , MESSAGE_404 ])
712
+ client = DurableOrchestrationClient (binding_string )
713
+ client ._post_async_request = mock_request .post
714
+
715
+ with pytest .raises (Exception ):
716
+ await client .resume (TEST_INSTANCE_ID , raw_reason )
717
+
718
+
719
+ @pytest .mark .asyncio
720
+ async def test_post_500_resume (binding_string ):
721
+ raw_reason = 'stuff and things'
722
+ reason = 'stuff%20and%20things'
723
+ mock_request = MockRequest (
724
+ expected_url = f"{ RPC_BASE_URL } instances/{ TEST_INSTANCE_ID } /resume?reason={ reason } " ,
725
+ response = [500 , MESSAGE_500 ])
726
+ client = DurableOrchestrationClient (binding_string )
727
+ client ._post_async_request = mock_request .post
728
+
729
+ with pytest .raises (Exception ):
730
+ await client .resume (TEST_INSTANCE_ID , raw_reason )
0 commit comments