Skip to content

Commit c9786c5

Browse files
authored
Merge pull request #360 from sartography/feature/remove-box
remove Box and associated tests
2 parents f59ad47 + 2b1fd2c commit c9786c5

14 files changed

+6
-433
lines changed

SpiffWorkflow/bpmn/PythonScriptEngineEnvironment.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# 02110-1301 USA
1919

2020
import copy
21-
import warnings
2221

2322

2423
class BasePythonScriptEngineEnvironment:
@@ -78,82 +77,3 @@ def check_for_overwrite(self, context, external_methods):
7877
f"function(s). Please change the following variable or " \
7978
f"field name(s) to something else: {func_overwrites}"
8079
raise ValueError(msg)
81-
82-
83-
class Box(dict):
84-
"""
85-
Example:
86-
m = Box({'first_name': 'Eduardo'}, last_name='Pool', age=24, sports=['Soccer'])
87-
"""
88-
89-
def __init__(self, *args, **kwargs):
90-
warnings.warn('The usage of Box has been deprecated.', DeprecationWarning, stacklevel=2)
91-
super(Box, self).__init__(*args, **kwargs)
92-
for arg in args:
93-
if isinstance(arg, dict):
94-
for k, v in arg.items():
95-
if isinstance(v, dict):
96-
self[k] = Box(v)
97-
else:
98-
self[k] = v
99-
100-
if kwargs:
101-
for k, v in kwargs.items():
102-
if isinstance(v, dict):
103-
self[k] = Box(v)
104-
else:
105-
self[k] = v
106-
107-
def __deepcopy__(self, memodict=None):
108-
if memodict is None:
109-
memodict = {}
110-
my_copy = Box()
111-
for k, v in self.items():
112-
my_copy[k] = copy.deepcopy(v)
113-
return my_copy
114-
115-
def __getattr__(self, attr):
116-
try:
117-
output = self[attr]
118-
except Exception:
119-
raise AttributeError(
120-
"Dictionary has no attribute '%s' " % str(attr))
121-
return output
122-
123-
def __setattr__(self, key, value):
124-
self.__setitem__(key, value)
125-
126-
def __setitem__(self, key, value):
127-
super(Box, self).__setitem__(key, value)
128-
self.__dict__.update({key: value})
129-
130-
def __getstate__(self):
131-
return self.__dict__
132-
133-
def __setstate__(self, state):
134-
self.__init__(state)
135-
136-
def __delattr__(self, item):
137-
self.__delitem__(item)
138-
139-
def __delitem__(self, key):
140-
super(Box, self).__delitem__(key)
141-
del self.__dict__[key]
142-
143-
@classmethod
144-
def convert_to_box(cls, data):
145-
if isinstance(data, dict):
146-
for key, value in data.items():
147-
if not isinstance(value, Box):
148-
data[key] = cls.convert_to_box(value)
149-
return Box(data)
150-
if isinstance(data, list):
151-
for idx, value in enumerate(data):
152-
data[idx] = cls.convert_to_box(value)
153-
return data
154-
return data
155-
156-
class BoxedTaskDataEnvironment(TaskDataEnvironment):
157-
def _prepare_context(self, context):
158-
Box.convert_to_box(context)
159-

tests/SpiffWorkflow/bpmn/BoxDeepCopyTest.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/SpiffWorkflow/bpmn/FeelExpressionEngineTest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# -*- coding: utf-8 -*-
21
import datetime
32

43
from SpiffWorkflow.bpmn.FeelLikeScriptEngine import FeelLikeScriptEngine, FeelInterval
5-
from SpiffWorkflow.bpmn.PythonScriptEngineEnvironment import BoxedTaskDataEnvironment
4+
from SpiffWorkflow.bpmn.PythonScriptEngineEnvironment import TaskDataEnvironment
65
from .BpmnWorkflowTestCase import BpmnWorkflowTestCase
76

87

@@ -12,7 +11,7 @@
1211
class FeelExpressionTest(BpmnWorkflowTestCase):
1312

1413
def setUp(self):
15-
self.expressionEngine = FeelLikeScriptEngine(environment=BoxedTaskDataEnvironment())
14+
self.expressionEngine = FeelLikeScriptEngine(environment=TaskDataEnvironment())
1615

1716
def testRunThroughExpressions(self):
1817
tests = [("string length('abcd')", 4, {}),
@@ -41,8 +40,6 @@ def testRunThroughExpressions(self):
4140
{}),
4241
("day of week('2020-05-07')", 4, {}),
4342
("day of week(a)", 0, {'a': datetime.datetime(2020, 5, 3)}),
44-
("list contains(a.b,'x')", True, {'a': {'b': ['a', 'x']}}), # combo
45-
("list contains(a.b,'c')", False, {'a': {'b': ['a', 'x']}}),
4643
("list contains(a.keys(),'b')", True, {'a': {'b': ['a', 'x']}}),
4744
("list contains(a.keys(),'c')", False, {'a': {'b': ['a', 'x']}}),
4845
]
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import unittest
2-
31
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
42
from SpiffWorkflow.bpmn.PythonScriptEngine import PythonScriptEngine
5-
from SpiffWorkflow.bpmn.PythonScriptEngineEnvironment import BoxedTaskDataEnvironment
3+
from SpiffWorkflow.bpmn.PythonScriptEngineEnvironment import TaskDataEnvironment
64

75
from .BaseTestCase import BaseTestCase
86

@@ -12,7 +10,7 @@ def setUp(self):
1210
self.spec, subprocesses = self.load_workflow_spec(
1311
'DMNMultiInstance.bpmn', 'Process_1', 'test_integer_decision_multi.dmn')
1412
self.workflow = BpmnWorkflow(self.spec)
15-
self.script_engine = PythonScriptEngine(environment=BoxedTaskDataEnvironment())
13+
self.script_engine = PythonScriptEngine(environment=TaskDataEnvironment())
1614
self.workflow.script_engine = self.script_engine
1715

1816
def testDmnHappy(self):
@@ -31,12 +29,3 @@ def testDmnSaveRestore(self):
3129
self.workflow.do_engine_steps()
3230
self.save_restore()
3331
self.assertEqual(self.workflow.data['stuff']['E']['y'], 'D')
34-
35-
36-
37-
def suite():
38-
return unittest.TestLoader().loadTestsFromTestCase(MultiInstanceDMNTest)
39-
40-
41-
if __name__ == '__main__':
42-
unittest.TextTestRunner(verbosity=2).run(suite())

tests/SpiffWorkflow/camunda/data/dmn/test_integer_decision_multi.dmn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:camunda="http://camunda.org/schema/1.0/dmn" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" id="definitions_1jblnbx" name="definitions" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="5.0.0">
2+
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:camunda="http://camunda.org/schema/1.0/dmn" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" id="definitions_1jblnbx" name="definitions" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="4.11.1">
33
<decision id="IntegerDecisionStringOutputTable" name="IntegerDecisionStringOutput">
44
<decisionTable id="decisionTable">
55
<input id="InputClause_1tm0ceq" label="x" biodi:width="192" camunda:inputVariable="">
66
<inputExpression id="LiteralExpression_04o7chw" typeRef="integer">
7-
<text>item.x</text>
7+
<text>item['x']</text>
88
</inputExpression>
99
</input>
1010
<output id="output1" label="They Label Y" name="item.y" typeRef="string" />

tests/SpiffWorkflow/dmn/feel_engine/FeelDictDecisionTest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import unittest
22

3-
from SpiffWorkflow.bpmn.PythonScriptEngineEnvironment import Box
4-
53
from .FeelDecisionRunner import FeelDecisionRunner
64

75

@@ -19,7 +17,6 @@ def test_string_decision_string_output1(self):
1917
"PEANUTS": {"delicious": True},
2018
"SPAM": {"delicious": False}
2119
}}
22-
Box.convert_to_box(data)
2320
res = self.runner.decide(data)
2421
self.assertEqual(res.description, 'They are allergic to peanuts')
2522

tests/SpiffWorkflow/dmn/feel_engine/FeelDictDotNotationDecisionTest.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/SpiffWorkflow/dmn/feel_engine/data/dict_dot_notation_decision_feel.dmn

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/SpiffWorkflow/dmn/python_engine/DictDotNotationDecisionTest.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/SpiffWorkflow/dmn/python_engine/DictDotNotationDecisionWeirdCharactersTest.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)