Skip to content

Commit a8663e8

Browse files
committed
test: cover create_job instantiation of WRAP_ACTIONS templates
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
1 parent 702c4a6 commit a8663e8

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎test/openjd/model_v0/v2023_09/test_wrap_actions.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from openjd.model import (
1414
DecodeValidationError,
15+
create_job,
1516
decode_environment_template,
1617
decode_job_template,
1718
)
@@ -262,3 +263,34 @@ def test_wrapped_action_timeout_in_wrap_hook_ok(self):
262263
"timeout": "{{ WrappedAction.Timeout }}",
263264
}
264265
_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

Comments
 (0)