mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-09 17:55:48 +00:00
12b7fa2b70
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
51 lines
2.1 KiB
Python
51 lines
2.1 KiB
Python
import os
|
|
import unittest
|
|
|
|
from SpiffWorkflow.dmn.engine.DMNEngine import DMNEngine
|
|
from SpiffWorkflow.dmn.parser.BpmnDmnParser import BpmnDmnParser
|
|
from SpiffWorkflow.dmn.serializer.task_spec_converters import \
|
|
BusinessRuleTaskConverter
|
|
from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase
|
|
from tests.SpiffWorkflow.dmn.DecisionRunner import DecisionRunner
|
|
from tests.SpiffWorkflow.dmn.python_engine.PythonDecisionRunner import \
|
|
PythonDecisionRunner
|
|
|
|
|
|
class HitPolicyTest(BpmnWorkflowTestCase):
|
|
PARSER_CLASS = BpmnDmnParser
|
|
|
|
def testHitPolicyUnique(self):
|
|
file_name = os.path.join(os.path.dirname(__file__), 'data', 'unique_hit.dmn')
|
|
runner = PythonDecisionRunner(file_name)
|
|
decision_table = runner.decision_table
|
|
self.assertEqual('UNIQUE', decision_table.hit_policy)
|
|
res = runner.result({'name': 'Larry'})
|
|
self.assertEqual(1, res['result'])
|
|
|
|
def testHitPolicyCollect(self):
|
|
file_name = os.path.join(os.path.dirname(__file__), 'data', 'collect_hit.dmn')
|
|
runner = PythonDecisionRunner(file_name)
|
|
decision_table = runner.decision_table
|
|
self.assertEqual('COLLECT', decision_table.hit_policy)
|
|
res = runner.result({'type': 'stooge'})
|
|
self.assertEqual(4, len(res['name']))
|
|
res = runner.result({'type': 'farmer'})
|
|
self.assertEqual(1, len(res['name']))
|
|
self.assertEqual('Elmer Fudd', res['name'][0])
|
|
|
|
def testSerializeHitPolicy(self):
|
|
file_name = os.path.join(os.path.dirname(__file__), 'data', 'collect_hit.dmn')
|
|
runner = PythonDecisionRunner(file_name)
|
|
decision_table = runner.decision_table
|
|
self.assertEqual("COLLECT", decision_table.hit_policy)
|
|
dict = BusinessRuleTaskConverter().decision_table_to_dict(decision_table)
|
|
new_table = BusinessRuleTaskConverter().decision_table_from_dict(dict)
|
|
self.assertEqual("COLLECT", new_table.hit_policy)
|
|
|
|
def suite():
|
|
return unittest.TestLoader().loadTestsFromTestCase(HitPolicyTest)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.TextTestRunner(verbosity=2).run(suite())
|