Fix WorkflowExecution event ids not increasing

This commit is contained in:
Jean-Baptiste Barth 2015-10-12 08:38:14 +02:00
parent a137e5c5c9
commit c72c198208
2 changed files with 10 additions and 1 deletions

View File

@ -105,7 +105,7 @@ class WorkflowExecution(object):
def next_event_id(self):
event_ids = [evt.event_id for evt in self._events]
return max(event_ids or [0])
return max(event_ids or [0]) + 1
def _add_event(self, *args, **kwargs):
evt = HistoryEvent(self.next_event_id(), *args, **kwargs)

View File

@ -200,6 +200,15 @@ def test_workflow_execution_start_decision_task():
wfe.events()[-1].event_type.should.equal("DecisionTaskStarted")
wfe.events()[-1].identity.should.equal("srv01")
def test_workflow_execution_history_events_ids():
wft = get_basic_workflow_type()
wfe = WorkflowExecution(wft, "ab1234")
wfe._add_event("WorkflowExecutionStarted", workflow_execution=wfe)
wfe._add_event("DecisionTaskScheduled", workflow_execution=wfe)
wfe._add_event("DecisionTaskStarted", workflow_execution=wfe, scheduled_event_id=2)
ids = [evt.event_id for evt in wfe.events()]
ids.should.equal([1, 2, 3])
# HistoryEvent
@freeze_time("2015-01-01 12:00:00")