|
19 | 19 | MESSAGE_500 = 'instance failed with unhandled exception'
|
20 | 20 | MESSAGE_501 = "well we didn't expect that"
|
21 | 21 |
|
| 22 | +TEST_ORCHESTRATOR = "MyDurableOrchestrator" |
| 23 | +EXCEPTION_ORCHESTRATOR_NOT_FOUND_EXMESSAGE = "The function <orchestrator> doesn't exist,"\ |
| 24 | + " is disabled, or is not an orchestrator function. Additional info: "\ |
| 25 | + "the following are the known orchestrator functions: <list>" |
| 26 | +EXCEPTION_ORCHESTRATOR_NOT_FOUND_MESSAGE = "One or more of the arguments submitted is incorrect" |
| 27 | +EXCEPTION_TYPE_ORCHESTRATOR_NOT_FOUND = "System.ArgumentException" |
| 28 | +STACK_TRACE = "' at Microsoft.Azure.WebJobs.Extensions.DurableTask..." |
22 | 29 |
|
23 | 30 | class MockRequest:
|
24 | 31 | def __init__(self, expected_url: str, response: [int, any]):
|
@@ -497,3 +504,39 @@ async def test_wait_or_response_check_status_response(binding_string):
|
497 | 504 | with pytest.raises(Exception):
|
498 | 505 | await client.wait_for_completion_or_create_check_status_response(
|
499 | 506 | None, TEST_INSTANCE_ID, timeout_in_milliseconds=500)
|
| 507 | + |
| 508 | +@pytest.mark.asyncio |
| 509 | +async def test_start_new_orchestrator_not_found(binding_string): |
| 510 | + """Test that we throw the right exception when the orchestrator is not found. |
| 511 | + """ |
| 512 | + status = dict(ExceptionMessage=EXCEPTION_ORCHESTRATOR_NOT_FOUND_EXMESSAGE, |
| 513 | + StackTrace=STACK_TRACE, |
| 514 | + Message=EXCEPTION_ORCHESTRATOR_NOT_FOUND_MESSAGE, |
| 515 | + ExceptionType=EXCEPTION_TYPE_ORCHESTRATOR_NOT_FOUND) |
| 516 | + mock_request = MockRequest(expected_url=f"{RPC_BASE_URL}orchestrators/{TEST_ORCHESTRATOR}", |
| 517 | + response=[400, status]) |
| 518 | + client = DurableOrchestrationClient(binding_string) |
| 519 | + client._post_async_request = mock_request.post |
| 520 | + |
| 521 | + with pytest.raises(Exception) as ex: |
| 522 | + await client.start_new(TEST_ORCHESTRATOR) |
| 523 | + ex.match(EXCEPTION_ORCHESTRATOR_NOT_FOUND_EXMESSAGE) |
| 524 | + |
| 525 | + |
| 526 | +@pytest.mark.asyncio |
| 527 | +async def test_start_new_orchestrator_internal_exception(binding_string): |
| 528 | + """Test that we throw the right exception when the extension fails internally. |
| 529 | + """ |
| 530 | + status = dict(ExceptionMessage=EXCEPTION_ORCHESTRATOR_NOT_FOUND_EXMESSAGE, |
| 531 | + StackTrace=STACK_TRACE, |
| 532 | + Message=EXCEPTION_ORCHESTRATOR_NOT_FOUND_MESSAGE, |
| 533 | + ExceptionType=EXCEPTION_TYPE_ORCHESTRATOR_NOT_FOUND) |
| 534 | + mock_request = MockRequest(expected_url=f"{RPC_BASE_URL}orchestrators/{TEST_ORCHESTRATOR}", |
| 535 | + response=[500, status]) |
| 536 | + client = DurableOrchestrationClient(binding_string) |
| 537 | + client._post_async_request = mock_request.post |
| 538 | + |
| 539 | + status_str = str(status) |
| 540 | + with pytest.raises(Exception) as ex: |
| 541 | + await client.start_new(TEST_ORCHESTRATOR) |
| 542 | + ex.match(status_str) |
0 commit comments