Beispiel #1
0
 def test_fail_none(self):
     self.assertEqual(self.exit.trigger(petriish.Result(True, 'exit out')),
                      'in')
     self.assertNotFinished(self.state)
     self.assertEqual(
         self.child.trigger(petriish.Result(True, 'child out')), 'in')
     self.assertFailed(self.state)
Beispiel #2
0
    def test_loop(self):
        self.assertEqual(self.exit.trigger(petriish.Result(False)), 'in')
        self.assertNotFinished(self.state)
        self.assertEqual(
            self.child.trigger(petriish.Result(True, 'child out')), 'in')
        self.assertNotFinished(self.state)

        # second loop
        self.assertEqual(self.exit.trigger(petriish.Result(True, 'exit out')),
                         'child out')
        self.assertEqual(self.child.trigger(petriish.Result(False)),
                         'child out')
Beispiel #3
0
    def test_subworkflows(self):
        sub_a = DummyCommand(name='a')
        sub_b = DummyCommand(name='b')
        pattern = petriish.Sequence([sub_a, sub_b])
        state = pattern.instantiate('in')

        self.assertNotFinished(state)
        state.start()
        self.assertNotFinished(state)
        self.assertEqual(sub_a.trigger(petriish.Result(True, 'a out')), 'in')
        self.assertNotFinished(state)
        self.assertEqual(sub_b.trigger(petriish.Result(False)), 'a out')
        self.assertFailed(state)
Beispiel #4
0
 def test_fail_both(self):
     self.assertEqual(self.exit.trigger(petriish.Result(False)), 'in')
     self.assertNotFinished(self.state)
     self.assertEqual(self.child.trigger(petriish.Result(False)), 'in')
     self.assertFailed(self.state)
Beispiel #5
0
 def test_success(self):
     self.assertEqual(self.exit.trigger(petriish.Result(True, 'exit out')),
                      'in')
     self.assertNotFinished(self.state)
     self.assertEqual(self.child.trigger(petriish.Result(False)), 'in')
     self.assertSucceeded(self.state, 'exit out')