Skip to content

Commit

Permalink
fix: use replace me tag in default value for param-value-origin
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Jose Leiva Palomo <[email protected]>
  • Loading branch information
AleJo2995 committed Dec 21, 2023
1 parent 928c7ba commit 8cfc8de
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/trestle/core/commands/author/profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ def test_param_value_origin_from_inherited_profile(tmp_trestle_dir: pathlib.Path
header, tree = md_api.processor.process_markdown(md_path)

assert header
assert header[const.SET_PARAMS_TAG]['ac-3.3_prm_1'][const.PROFILE_PARAM_VALUE_ORIGIN] == 'Added by control owner'
assert header[const.SET_PARAMS_TAG]['ac-3.3_prm_1'][const.PROFILE_PARAM_VALUE_ORIGIN] == const.REPLACE_ME_PLACEHOLDER
header[const.SET_PARAMS_TAG]['ac-3.3_prm_1'][const.PROFILE_PARAM_VALUE_ORIGIN
] = 'Needed to change param value origin'
md_api.write_markdown_with_header(md_path, header, tree.content.raw_text)
Expand Down
11 changes: 6 additions & 5 deletions trestle/common/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,13 @@
# the parameter value is made up of the values from the other parameters. For parameters
# that aggregate, profile-values is not applicable.
#
# If the value of property param-value-origin needs to be changed, please
# insert a new property called profile-param-value-origin below and place the value there
# instead of replacing the original param-value-origin as follows:
# Property param-value-origin is meant for putting the origin from where that parameter comes from.
# In order to be changed in the current profile, profile-param-value-origin property will be displayed with
# the placeholder "<REPLACE_ME>" for you to be replaced. If a parameter already has a param-value-origin
# coming from an inherited profile, do no change this value, instead use profile-param-value-origin as follows:
#
# param-value-origin: this is the original value DO NOT REPLACE
# profile-param-value-origin: place the new value required HERE
# param-value-origin: DO NOT REPLACE - this is the original value
# profile-param-value-origin: <REPLACE_ME> - replace the new value required HERE
#
"""

Expand Down
2 changes: 1 addition & 1 deletion trestle/core/catalog/catalog_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def read_additional_content(
# verifies if at control profile edition the param value origin was modified
# through the profile-param-value-origin tag
if const.PROFILE_PARAM_VALUE_ORIGIN in param_dict:
if param_dict[const.PROFILE_PARAM_VALUE_ORIGIN] != const.ADDED_BY_CONTROL_OWNER:
if param_dict[const.PROFILE_PARAM_VALUE_ORIGIN] != const.REPLACE_ME_PLACEHOLDER:
param_dict[const.PARAM_VALUE_ORIGIN] = param_dict[const.PROFILE_PARAM_VALUE_ORIGIN]
param_dict.pop(const.PROFILE_PARAM_VALUE_ORIGIN)
else:
Expand Down
4 changes: 2 additions & 2 deletions trestle/core/catalog/catalog_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _construct_set_parameters_dict(
if context.purpose == ContextPurpose.PROFILE:
new_dict[const.PROFILE_PARAM_VALUE_ORIGIN] = prof_param_value_origin
else:
new_dict[const.PROFILE_PARAM_VALUE_ORIGIN] = const.ADDED_BY_CONTROL_OWNER
new_dict[const.PROFILE_PARAM_VALUE_ORIGIN] = const.REPLACE_ME_PLACEHOLDER
# then insert the original, incoming values as values
if param_id in control_param_dict:
orig_param = control_param_dict[param_id]
Expand Down Expand Up @@ -195,7 +195,7 @@ def _construct_set_parameters_dict(
'id': param_id,
}
new_dict[const.PROFILE_VALUES] = [const.REPLACE_ME_PLACEHOLDER]
new_dict[const.PROFILE_PARAM_VALUE_ORIGIN] = const.ADDED_BY_CONTROL_OWNER
new_dict[const.PROFILE_PARAM_VALUE_ORIGIN] = const.REPLACE_ME_PLACEHOLDER
if param_value_origin is not None:
if context.purpose == ContextPurpose.PROFILE:
new_dict[const.PARAM_VALUE_ORIGIN] = param_value_origin
Expand Down

0 comments on commit 8cfc8de

Please sign in to comment.