Example #1
0
class OrderEventType(EventType):
    """
        Order event type. Models the user journey through specifying an order
        for a pizza as described here:
        https://globality.atlassian.net/wiki/spaces/GLOB/pages/917733426/Product+Spec+Ordering+a+Pizza

    """

    # NB: Our state machines always start with an initial event
    OrderInitialized = event_info(follows=nothing(), )

    PizzaCreated = event_info(follows=any_of(
        "OrderInitialized",
        "PizzaCustomizationFinished",
    ), )

    PizzaToppingAdded = event_info(follows=any_of(
        "PizzaCreated",
        "PizzaToppingAdded",
    ), )

    PizzaCustomizationFinished = event_info(follows=any_of(
        "PizzaToppingAdded", ), )

    OrderDeliveryDetailsAdded = event_info(
        follows=event("PizzaCustomizationFinished"), )

    OrderSubmitted = event_info(follows=event("OrderDeliveryDetailsAdded"), )

    OrderSatisfied = event_info(follows=event("OrderSubmitted"), )

    OrderFulfilled = event_info(follows=event("OrderSubmitted"), )
Example #2
0
class IllegalEventType(EventType):
    # Event type with  non valid auto transition event
    CREATED = event_info()
    ASSIGNED = event_info(
        follows=event("CREATED"),
        auto_transition=True,
    )
    SCHEDULED = event_info(
        follows=event("CREATED"),
        auto_transition=True,
    )
Example #3
0
class SimpleTestObjectEventType(EventType):
    CREATED = event_info(
        follows=nothing(),
        accumulate=keep(),
    )
    READY = event_info(
        follows=event("CREATED"),
        accumulate=keep(),
    )
    DONE = event_info(
        follows=event("READY"),
        accumulate=keep(),
    )
Example #4
0
class AdvancedTaskEventType(Enum):
    REASSIGNED = event_info(
        follows=event("STARTED"),
        accumulate=keep(),
        requires=["assignee"],
    )
    RESCHEDULED = event_info(
        follows=event("STARTED"),
        accumulate=keep(),
        requires=["deadline"],
    )
    REVISED = event_info(
        follows=any_of("CREATED", "STARTED"),
        accumulate=alias("CREATED"),
        restarting=True,
    )
Example #5
0
class BasicTaskEventType(EventType):
    CREATED = event_info(follows=nothing(), )
    ASSIGNED = event_info(
        follows=all_of("CREATED", but_not("ASSIGNED")),
        accumulate=union(),
        requires=["assignee"],
    )
    SCHEDULED = event_info(
        follows=all_of("CREATED", but_not("SCHEDULED")),
        accumulate=union(),
        requires=["deadline"],
    )
    STARTED = event_info(follows=all_of("ASSIGNED", "SCHEDULED"), )
    CANCELED = event_info(follows=event("STARTED"), )
    COMPLETED = event_info(follows=event("STARTED"), )
    ENDED = event_info(
        follows=event("COMPLETED"),
        auto_transition=True,
    )
def test_all_of():
    transition = all_of(
        event("CREATED"),
        event("ASSIGNED"),
    )

    assert_that(
        bool(transition),
        is_(equal_to(True)),
    )
    assert_that(
        transition(TaskEventType,
                   [TaskEventType.CREATED, TaskEventType.ASSIGNED]),
        is_(equal_to(True)),
    )
    assert_that(
        transition(TaskEventType, [TaskEventType.CREATED]),
        is_(equal_to(False)),
    )
    assert_that(
        transition(TaskEventType, []),
        is_(equal_to(False)),
    )
Example #7
0
class ActivityEventType(EventType):
    CREATED = event_info(follows=nothing(), )
    CANCELED = event_info(follows=event("CREATED"), )