|
13 | 13 | from tests.mocks import ( |
14 | 14 | ActionStep, |
15 | 15 | ActionStepExecutionOrderer, |
| 16 | + ActionStepPrefixMethods, |
16 | 17 | ActionStepWithContexts, |
17 | 18 | ActionStepWithError, |
18 | 19 | ActionStepWithInitialContext, |
@@ -292,6 +293,35 @@ def test_execution_orderer(self): |
292 | 293 | expected_value, |
293 | 294 | ) |
294 | 295 |
|
| 296 | + def test_execution_orderer_prefix_methods(self): |
| 297 | + """_execution_orderer must not match 'run' against a 'def run_all' line.""" |
| 298 | + controller = Execution( |
| 299 | + task=self.task, |
| 300 | + workflow_id=self.workflow_id, |
| 301 | + previous_context=Context(), |
| 302 | + ) |
| 303 | + |
| 304 | + class_instance = ActionStepPrefixMethods(task=controller.task).storage |
| 305 | + callable_list = [ |
| 306 | + func |
| 307 | + for func in dir(class_instance) |
| 308 | + if controller._is_action(class_instance, func) |
| 309 | + ] |
| 310 | + |
| 311 | + result = controller._execution_orderer( |
| 312 | + callable_list=callable_list, class_instance=class_instance |
| 313 | + ) |
| 314 | + result_names = [name for _, name in result] |
| 315 | + |
| 316 | + # Both methods must appear exactly once |
| 317 | + self.assertEqual(result_names.count("run"), 1) |
| 318 | + self.assertEqual(result_names.count("run_all"), 1) |
| 319 | + |
| 320 | + # 'run' must appear at an earlier line than 'run_all' |
| 321 | + line_run = next(idx for idx, name in result if name == "run") |
| 322 | + line_run_all = next(idx for idx, name in result if name == "run_all") |
| 323 | + self.assertLess(line_run, line_run_all) |
| 324 | + |
295 | 325 | def test_valid_objects(self): |
296 | 326 | valid_objects = [ |
297 | 327 | "", |
|
0 commit comments