spiff-arena/tests/SpiffWorkflow/dmn/DmnFailVersionTest.py
Jon Herron 0892db6fa7 Squashed 'SpiffWorkflow/' content from commit 63db3e4
git-subtree-dir: SpiffWorkflow
git-subtree-split: 63db3e45947ec66b8d0efc2c74064004f8ff482c
2022-10-12 10:19:53 -04:00

44 lines
1.4 KiB
Python

import unittest
import os
from SpiffWorkflow.dmn.parser.BpmnDmnParser import BpmnDmnParser
class DmnVersionTest(unittest.TestCase):
def setUp(self):
self.parser = BpmnDmnParser()
def testLoadV1_2_supported(self):
self._assert_parse_all_pass('v1_2_supported')
def testLoadV1_2_unsupported(self):
self._assert_parse_all_fail('v1_2_unsupported')
def testLoadV1_3_supported(self):
self._assert_parse_all_pass('v1_3_supported')
def testLoadV1_3_unsupported(self):
self._assert_parse_all_fail('v1_3_unsupported')
def _assert_parse_all_pass(self, dir_path):
dirname = os.path.join(os.path.dirname(__file__), 'data', 'dmn_version_test', dir_path)
self.parser.add_dmn_files_by_glob(f'{dirname}/*.dmn')
for parser in self.parser.dmn_parsers.values():
parser.parse()
self.assertIsNotNone(parser.get_id())
self.assertIsNotNone(parser.get_name())
def _assert_parse_all_fail(self, dir_path):
dirname = os.path.join(os.path.dirname(__file__), 'data', 'dmn_version_test', dir_path)
with self.assertRaises(IndexError):
self.parser.add_dmn_files_by_glob(f'{dirname}/*.dmn')
def suite():
return unittest.TestLoader().loadTestsFromTestCase(DmnVersionTest)
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())