Skip to content

Commit

Permalink
#606 fixed dependant list values setting in case of constant parent
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed Jan 7, 2023
1 parent 1567a5c commit 83d2b1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/model/script_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ def get_sort_key(parameter):
if required_parameters and any(r not in processed for r in required_parameters):
continue

value = parameter.normalize_user_value(param_values.get(parameter.name))
if parameter.constant:
value = parameter.default
else:
value = parameter.normalize_user_value(param_values.get(parameter.name))

validation_error = parameter.validate_value(value)
if validation_error:
if skip_invalid_parameters:
Expand Down
40 changes: 27 additions & 13 deletions src/tests/script_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,21 @@ def test_set_all_values_for_included(self):

self.assertEqual(values, config_model.parameter_values)

def test_set_all_values_for_dependant_on_constant(self):
included_path = test_utils.write_script_config({'parameters': [
create_script_param_config('included_param1', values_script='echo ${p1}'),
]}, 'included')
config_model = _create_config_model(
'main_conf',
config={
'include': included_path,
'parameters': [create_script_param_config('p1', constant=True, default='t1\nt2\nt3')]})

values = {'included_param1': 't2'}
config_model.set_all_param_values(values)

self.assertEqual({'included_param1': 't2', 'p1': 't1\nt2\nt3'}, config_model.parameter_values)

def test_dynamic_include_add_parameter_with_default(self):
(config_model, included_path) = self.prepare_config_model_with_included([
create_script_param_config('included_param', default='abc 123')
Expand Down Expand Up @@ -853,21 +868,20 @@ def test_get_sorted_with_parameters(self):
])
self.assertEqual(expected, config)


def test_json_comments(self):
config = get_sorted_config(custom_json.loads(
"""{
// Comment 1
"parameters": [
// Comment 2
{"name": "param2", "description": "desc 1"},
{"type": "int", "name": "paramA"},
{"default": "false", "name": "param1", "no_value": true}
],
// Comment 3
"name": "Conf X"
}""")
)
"""{
// Comment 1
"parameters": [
// Comment 2
{"name": "param2", "description": "desc 1"},
{"type": "int", "name": "paramA"},
{"default": "false", "name": "param1", "no_value": true}
],
// Comment 3
"name": "Conf X"
}""")
)

expected = OrderedDict([
('name', 'Conf X'),
Expand Down

0 comments on commit 83d2b1c

Please sign in to comment.