def test_context_creation_without_events(monkeypatch): """Check the basic context creation. """ current_context = context.ExecutionContext() assert not current_context.current assert not current_context.workflow_input
def test_context_creation_with_events(monkeypatch): """Test context creation with events. """ from tests.fixtures import decider as poll current_context = context.ExecutionContext(poll.history.get('events')) assert current_context.current == {'k': 'v'}
def test_get_workflow_execution_info(monkeypatch): """Check that the workflow execution info are properly extracted """ from tests.fixtures import decider as poll current_context = context.ExecutionContext() current_context.set_workflow_execution_info(poll.history, 'dev') # Test extracting workflow execution info assert current_context.current == { 'execution.domain': 'dev', 'execution.run_id': '123abc=', 'execution.workflow_id': 'test-workflow-id' }
def get_current_context(events): """Get the current context from the list of events. Each activity returns bits of information that needs to be provided to the next activities. Args: events (list): List of events. Return: dict: The current context. """ events = sorted(events, key=lambda item: item.get('eventId')) execution_context = context.ExecutionContext(events) return execution_context