burnettk 12b7fa2b70 Squashed 'SpiffWorkflow/' changes from 46d3de27f..ffb168675
ffb168675 Option to run tests in parallel (#271)
062eaf15d another hot match -- assure hit policy is correctly passed through.
c79ee8407 Quick patch the DMN hit policy to fix a dump mistake.
36dd1b23a Fix ResourceWarning: unclosed file BpmnParser.py:60 (#270)
bba7ddf54 Merge pull request #268 from sartography/feature/multiple-event-definition
8cf770985 remove unused import
9d31e035e make multiple throw events work with start events
890c4b921 add throw support for multiple events
c1fc55660 add support for catching parallel multiple event definitions
511830b67 add event based gateway
56bd858dc add event type for multiple events

git-subtree-dir: SpiffWorkflow
git-subtree-split: ffb1686757f944065580dd2db8def73d6c1f0134
2022-12-10 23:39:00 -05:00

54 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
import os
import unittest
from tests.SpiffWorkflow.util import run_workflow
from .TaskSpecTest import TaskSpecTest
from SpiffWorkflow.task import TaskState
from SpiffWorkflow.specs.Execute import Execute
class ExecuteTest(TaskSpecTest):
CORRELATE = Execute
def create_instance(self):
if 'testtask' in self.wf_spec.task_specs:
del self.wf_spec.task_specs['testtask']
return Execute(self.wf_spec,
'testtask',
description='foo',
args=self.cmd_args)
def setUp(self):
script_path = os.path.join(os.path.dirname(__file__), '..', 'ExecuteProcessMock.py')
self.cmd_args = ["python", script_path]
TaskSpecTest.setUp(self)
def testConstructor(self):
TaskSpecTest.testConstructor(self)
self.assertEqual(self.spec.args, self.cmd_args)
def testPattern(self):
"""
Tests that we can create a task that executes a shell command
and that the workflow can be called to complete such tasks.
"""
self.wf_spec.start.connect(self.spec)
expected = 'Start\n testtask\n'
workflow = run_workflow(self, self.wf_spec, expected, '')
task = workflow.get_tasks_from_spec_name('testtask')[0]
self.assertEqual(task.state_history, [TaskState.FUTURE,
TaskState.WAITING,
TaskState.READY,
TaskState.COMPLETED])
self.assertIn(b'127.0.0.1', task.results[0])
def suite():
return unittest.TestLoader().loadTestsFromTestCase(ExecuteTest)
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())