-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathtest_bc_action.py
More file actions
219 lines (181 loc) · 7.84 KB
/
test_bc_action.py
File metadata and controls
219 lines (181 loc) · 7.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import unittest
from conductor.client.http.models.action import Action
class TestActionBackwardCompatibility(unittest.TestCase):
"""
Backward compatibility test for Action model.
Principles:
- ✅ Allow additions (new fields, new enum values)
- ❌ Prevent removals (missing fields, removed enum values)
- ❌ Prevent changes (field type changes, field name changes)
"""
def setUp(self):
"""Set up test fixtures with known baseline configuration."""
self.baseline_swagger_types = {
'action': 'str',
'start_workflow': 'StartWorkflow',
'complete_task': 'TaskDetails',
'fail_task': 'TaskDetails',
'expand_inline_json': 'bool'
}
self.baseline_attribute_map = {
'action': 'action',
'start_workflow': 'start_workflow',
'complete_task': 'complete_task',
'fail_task': 'fail_task',
'expand_inline_json': 'expandInlineJSON'
}
self.baseline_allowed_action_values = ["start_workflow", "complete_task", "fail_task"]
def test_required_fields_exist(self):
"""Verify all baseline fields still exist in the model."""
action = Action()
# Check that all baseline swagger_types fields exist
for field_name in self.baseline_swagger_types.keys():
self.assertTrue(
hasattr(action, field_name),
f"Missing required field: {field_name}"
)
self.assertTrue(
hasattr(action, f"_{field_name}"),
f"Missing private field: _{field_name}"
)
def test_swagger_types_compatibility(self):
"""Verify existing swagger_types haven't changed."""
current_swagger_types = Action.swagger_types
# Check all baseline types are preserved
for field_name, expected_type in self.baseline_swagger_types.items():
self.assertIn(
field_name,
current_swagger_types,
f"Field {field_name} removed from swagger_types"
)
self.assertEqual(
current_swagger_types[field_name],
expected_type,
f"Field {field_name} type changed from {expected_type} to {current_swagger_types[field_name]}"
)
def test_attribute_map_compatibility(self):
"""Verify existing attribute_map hasn't changed."""
current_attribute_map = Action.attribute_map
# Check all baseline mappings are preserved
for field_name, expected_json_key in self.baseline_attribute_map.items():
self.assertIn(
field_name,
current_attribute_map,
f"Field {field_name} removed from attribute_map"
)
self.assertEqual(
current_attribute_map[field_name],
expected_json_key,
f"Field {field_name} JSON mapping changed from {expected_json_key} to {current_attribute_map[field_name]}"
)
def test_constructor_parameters_compatibility(self):
"""Verify constructor accepts all baseline parameters."""
# Should be able to create Action with all baseline parameters
try:
action = Action(
action="start_workflow",
start_workflow=None,
complete_task=None,
fail_task=None,
expand_inline_json=True
)
self.assertIsInstance(action, Action)
except TypeError as e:
self.fail(f"Constructor signature changed - baseline parameters rejected: {e}")
def test_property_getters_exist(self):
"""Verify all baseline property getters still exist."""
action = Action()
for field_name in self.baseline_swagger_types.keys():
# Check getter property exists
self.assertTrue(
hasattr(Action, field_name),
f"Missing property getter: {field_name}"
)
# Check it's actually a property
self.assertIsInstance(
getattr(Action, field_name),
property,
f"{field_name} is not a property"
)
def test_property_setters_exist(self):
"""Verify all baseline property setters still exist."""
action = Action()
for field_name in self.baseline_swagger_types.keys():
# Check setter exists by trying to access it
prop = getattr(Action, field_name)
self.assertIsNotNone(
prop.fset,
f"Missing property setter: {field_name}"
)
def test_action_enum_validation_compatibility(self):
"""Verify action field validation rules are preserved."""
action = Action()
# Test that baseline allowed values still work
for allowed_value in self.baseline_allowed_action_values:
try:
action.action = allowed_value
self.assertEqual(action.action, allowed_value)
except ValueError:
self.fail(f"Previously allowed action value '{allowed_value}' now rejected")
# Test that invalid values are still rejected
with self.assertRaises(ValueError):
action.action = "invalid_action"
def test_field_type_assignments(self):
"""Verify baseline field types can still be assigned."""
action = Action()
# Test string assignment to action
action.action = "start_workflow"
self.assertEqual(action.action, "start_workflow")
# Test boolean assignment to expand_inline_json
action.expand_inline_json = True
self.assertTrue(action.expand_inline_json)
action.expand_inline_json = False
self.assertFalse(action.expand_inline_json)
def test_to_dict_method_compatibility(self):
"""Verify to_dict method still works and includes baseline fields."""
action = Action(
action="complete_task",
expand_inline_json=True
)
result_dict = action.to_dict()
# Check method still works
self.assertIsInstance(result_dict, dict)
# Check baseline fields are included in output
expected_fields = set(self.baseline_swagger_types.keys())
actual_fields = set(result_dict.keys())
self.assertTrue(
expected_fields.issubset(actual_fields),
f"Missing baseline fields in to_dict output: {expected_fields - actual_fields}"
)
def test_to_str_method_compatibility(self):
"""Verify to_str method still works."""
action = Action(action="fail_task")
try:
str_result = action.to_str()
self.assertIsInstance(str_result, str)
except Exception as e:
self.fail(f"to_str method failed: {e}")
def test_equality_methods_compatibility(self):
"""Verify __eq__ and __ne__ methods still work."""
action1 = Action(action="start_workflow", expand_inline_json=True)
action2 = Action(action="start_workflow", expand_inline_json=True)
action3 = Action(action="complete_task", expand_inline_json=False)
try:
# Test equality
self.assertTrue(action1 == action2)
self.assertFalse(action1 == action3)
# Test inequality
self.assertFalse(action1 != action2)
self.assertTrue(action1 != action3)
except Exception as e:
self.fail(f"Equality methods failed: {e}")
def test_repr_method_compatibility(self):
"""Verify __repr__ method still works."""
action = Action(action="start_workflow")
try:
repr_result = repr(action)
self.assertIsInstance(repr_result, str)
except Exception as e:
self.fail(f"__repr__ method failed: {e}")
if __name__ == '__main__':
unittest.main()