|
12 | 12 |
|
13 | 13 | from openjd.model import ( |
14 | 14 | DecodeValidationError, |
| 15 | + create_job, |
15 | 16 | decode_environment_template, |
16 | 17 | decode_job_template, |
17 | 18 | ) |
@@ -262,3 +263,34 @@ def test_wrapped_action_timeout_in_wrap_hook_ok(self): |
262 | 263 | "timeout": "{{ WrappedAction.Timeout }}", |
263 | 264 | } |
264 | 265 | _decode(_env_template(actions, extensions=["WRAP_ACTIONS", "EXPR", "FEATURE_BUNDLE_1"])) |
| 266 | + |
| 267 | + |
| 268 | +# ── RFC 0008 create_job instantiation ────────────────────────────────── |
| 269 | +# |
| 270 | +# create_job re-validates the instantiated Job submodels without a parsing |
| 271 | +# context. The EnvironmentActions extension gate must therefore only enforce |
| 272 | +# the WRAP_ACTIONS/EXPR requirement at decode time (context present), not at |
| 273 | +# instantiation time -- otherwise a template that decodes cleanly fails when a |
| 274 | +# Job is generated from it. |
| 275 | + |
| 276 | + |
| 277 | +class TestWrapActionsCreateJob: |
| 278 | + def test_create_job_with_wrap_env_succeeds(self): |
| 279 | + # A wrap-defining jobEnvironment decodes AND instantiates into a Job. |
| 280 | + # Regression: instantiate_model used to re-fire the WRAP_ACTIONS |
| 281 | + # extension gate (no context) and raise "require the WRAP_ACTIONS |
| 282 | + # extension." |
| 283 | + jt = _decode_job(_job_template(job_environments=[_wrap_env("W")])) |
| 284 | + job = create_job(job_template=jt, job_parameter_values={}) |
| 285 | + env_actions = job.jobEnvironments[0].script.actions |
| 286 | + assert env_actions.onWrapEnvEnter is not None |
| 287 | + assert env_actions.onWrapTaskRun is not None |
| 288 | + assert env_actions.onWrapEnvExit is not None |
| 289 | + |
| 290 | + def test_create_job_with_step_env_wrap_succeeds(self): |
| 291 | + jt = _decode_job( |
| 292 | + _job_template(steps=[_plain_step("S", step_environments=[_wrap_env("W")])]) |
| 293 | + ) |
| 294 | + job = create_job(job_template=jt, job_parameter_values={}) |
| 295 | + step_env_actions = job.steps[0].stepEnvironments[0].script.actions |
| 296 | + assert step_env_actions.onWrapTaskRun is not None |
0 commit comments