def test_event_raised_return_completed_task():
    timestamp = datetime.now()
    json_input = '{"test":"somecontent"}'
    expected_action = WaitForExternalEventAction("A")
    context_builder = ContextBuilder('test_simple_function')
    context_builder.add_event_raised_event(name="A",
                                           input_=json_input,
                                           timestamp=timestamp,
                                           id_=1)

    returned_task = wait_for_external_event_task(
        context_builder.history_events, "A")
    expected_task = Task(is_completed=True,
                         is_faulted=False,
                         action=expected_action,
                         result=json.loads(json_input),
                         timestamp=timestamp.replace(tzinfo=tzutc()),
                         id_=1)

    assert_tasks_equal(expected_task, returned_task)
Пример #2
0
def add_call_entity_completed_events(
        context_builder: ContextBuilder, op: str, instance_id=str, input_=None):
    context_builder.add_event_sent_event(instance_id)
    context_builder.add_orchestrator_completed_event()
    context_builder.add_orchestrator_started_event()
    context_builder.add_event_raised_event(name="0000", id_=0, input_=input_, is_entity=True)