@@ -1011,3 +1011,60 @@ def test_matches_the_rust_implementation(self) -> None:
10111011 compared += 1
10121012 # Guard against the assertions above passing vacuously
10131013 assert compared > 0
1014+
1015+ def test_queue_environment_parameters_reach_the_tables (self ) -> None :
1016+ """Parameters contributed by an external environment template — a queue
1017+ environment, in service terms — must appear in the returned tables.
1018+
1019+ Note the job template itself cannot *reference* such a parameter: the
1020+ caller merges the environment's parameterDefinitions into the template
1021+ before decode. What this pins is that the values reach the symbol tables,
1022+ which is this API's part of that flow.
1023+ """
1024+ from openjd .model import create_job_with_symbol_tables
1025+
1026+ # GIVEN
1027+ job_template = decode_job_template (
1028+ template = {
1029+ "specificationVersion" : "jobtemplate-2023-09" ,
1030+ "extensions" : ["EXPR" ],
1031+ "name" : "queue-env-job" ,
1032+ "steps" : [
1033+ {
1034+ "name" : "render" ,
1035+ "script" : {"actions" : {"onRun" : {"command" : "echo" , "args" : ["hi" ]}}},
1036+ }
1037+ ],
1038+ },
1039+ supported_extensions = ["EXPR" ],
1040+ )
1041+ env_template = decode_environment_template (
1042+ template = dict (
1043+ specificationVersion = "environment-2023-09" ,
1044+ environment = minimal_environment_2023_09 ,
1045+ parameterDefinitions = [{"name" : "Bar" , "type" : "STRING" , "default" : "fromQueueEnv" }],
1046+ )
1047+ )
1048+ parameter_values = preprocess_job_parameters (
1049+ job_template = job_template ,
1050+ job_parameter_values = {},
1051+ job_template_dir = Path (),
1052+ current_working_dir = Path (),
1053+ allow_job_template_dir_walk_up = True ,
1054+ environment_templates = [env_template ],
1055+ )
1056+
1057+ # WHEN
1058+ result = create_job_with_symbol_tables (
1059+ job_template = job_template ,
1060+ job_parameter_values = parameter_values ,
1061+ environment_templates = [env_template ],
1062+ )
1063+
1064+ # THEN — the queue environment's parameter is in job scope, and inherited
1065+ # by step scope
1066+ assert self ._entries (result .job_symbol_table )["Param.Bar" ] == ("string" , "fromQueueEnv" )
1067+ assert self ._entries (result .step_symbol_tables ["render" ])["Param.Bar" ] == (
1068+ "string" ,
1069+ "fromQueueEnv" ,
1070+ )
0 commit comments