Example #1
0
    arg_map={MakePie.MAKER: ThrowPieContext.THROWER},
    # we bind from the returned result back to the context
    result_map=MakePie.ResultMap(ThrowPieContext)
)
ThrowThingStep = Step(
    ThrowThing(),
    arg_map=ThrowThing.AutoMap({ThrowThing.ACTOR: ThrowPieContext.THROWER,
                                ThrowThing.THING: ThrowPieContext.PIE}),
    result_map={ThrowPieContext.WAS_HIT: 'hit'}
)


""" There are a few ways to build up a workflow. By constructor..."""
ThrowPieWorkflowA = Workflow(steps=[
    IsUserAuthorizedStep,
    MakePieStep,
    ThrowThingStep,
])

""" Or using add_step..."""
ThrowPieWorkflowB = Workflow().add_step(
    IsUserAuthorizedStep
).add_step(
    MakePieStep
).add_step(
    ThrowThingStep
)

""" Or using the overloaded addition operator."""
EmptyWorkflow = Workflow()
ThrowPieWorkflowC_A = EmptyWorkflow + IsUserAuthorizedStep + MakePieStep
Example #2
0
 def test_bad_concatenation(self):
     with nose.tools.assert_raises(TypeError):
         Workflow() + 10
Example #3
0
    def test_default_on_error(self):
        m = Mock(side_effect=ValueError)

        w = Workflow(steps=[m])
        with nose.tools.assert_raises(ValueError):  # @UndefinedVariable
            w(DefaultContext())
Example #4
0
 def test_skip(self):
     w = Workflow(steps=[self.skip])
     ctx = w(DefaultContext())
     assert ctx.replies == []