def test_all_the_args():
    orchestration_started = get_event(HistoryEventType.ORCHESTRATOR_STARTED)
    execution_started = get_event(HistoryEventType.EXECUTION_STARTED)
    history = [orchestration_started, execution_started]
    response = dict(name=TEST_NAME,
                    instanceId=TEST_INSTANCE_ID,
                    createdTime=TEST_CREATED_TIME,
                    lastUpdatedTime=TEST_LAST_UPDATED_TIME,
                    input=TEST_INPUT,
                    output=TEST_OUTPUT,
                    runtimeStatus=TEST_RUNTIME_STATUS,
                    customStatus=TEST_CUSTOM_STATUS,
                    history=history)

    result = DurableOrchestrationStatus.from_json(response)

    assert result.runtime_status.name == TEST_RUNTIME_STATUS
    assert result.custom_status == TEST_CUSTOM_STATUS
    assert result.instance_id == TEST_INSTANCE_ID
    assert result.output == TEST_OUTPUT
    assert result.created_time == dt_parse(TEST_CREATED_TIME)
    assert result.last_updated_time == dt_parse(TEST_LAST_UPDATED_TIME)
    assert result.input_ == TEST_INPUT
    assert result.name == TEST_NAME
    assert result.history[0][
        'EventType'] == HistoryEventType.ORCHESTRATOR_STARTED
    assert result.history[1]['EventType'] == HistoryEventType.EXECUTION_STARTED
async def test_wait_or_response_200_failed(binding_string):
    status = dict(createdTime=TEST_CREATED_TIME,
                  lastUpdatedTime=TEST_LAST_UPDATED_TIME,
                  runtimeStatus="Failed")
    mock_request = MockRequest(expected_url=f"{RPC_BASE_URL}instances/{TEST_INSTANCE_ID}",
                               response=[200, status])
    client = DurableOrchestrationClient(binding_string)
    client._get_async_request = mock_request.get

    result = await client.wait_for_completion_or_create_check_status_response(
        None, TEST_INSTANCE_ID)
    assert result is not None
    assert result.status_code == 500
    assert result.mimetype == 'application/json'
    assert json.loads(result.get_body().decode()) == DurableOrchestrationStatus.from_json(
        status).to_json()
Exemplo n.º 3
0
def test_no_args():
    response = ''

    result = DurableOrchestrationStatus.from_json(response)

    assert result is not None