Skip to content

Commit 8610135

Browse files
ADD Backward compatibility tests (#289)
1 parent f228526 commit 8610135

65 files changed

Lines changed: 17858 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/backwardcompatibility/__init__.py

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

0 commit comments

Comments
 (0)