Skip to content

Commit

Permalink
fix: add step to ignore param-value-origin if no replacement was done…
Browse files Browse the repository at this point in the history
… in profile-param-value-origin

Signed-off-by: Alejandro Jose Leiva Palomo <[email protected]>
  • Loading branch information
AleJo2995 committed Dec 7, 2023
1 parent 52c8920 commit 1c984a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/trestle/core/commands/author/profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,20 @@ def test_param_value_origin_from_inherited_profile(tmp_trestle_dir: pathlib.Path

assert Trestle().run() == 0

# assemble based on set_parameters_flag
test_args = f'trestle author profile-assemble -n test_profile_a -m {md_name} -o {assembled_prof_name}'.split()
test_args.append('-sp')
assembled_prof_dir = tmp_trestle_dir / 'profiles/my_assembled_prof'
assembled_prof_dir.mkdir()
monkeypatch.setattr(sys, 'argv', test_args)
assert Trestle().run() == 0

profile, _ = ModelUtils.load_model_for_class(tmp_trestle_dir, 'my_assembled_prof',
prof.Profile, FileContentType.JSON)

# grabs parameter ac-3.3_prm_1 and verify param-value-origin wasn´t added as profile-param-value-origin wasn´t modified
assert profile.modify.set_parameters[18].props is None

md_path = tmp_trestle_dir / 'my_md' / 'ac' / 'ac-3.3.md'

assert md_path.exists()
Expand All @@ -1406,10 +1420,9 @@ def test_param_value_origin_from_inherited_profile(tmp_trestle_dir: pathlib.Path
md_api.write_markdown_with_header(md_path, header, tree.content.raw_text)

# assemble based on set_parameters_flag
test_args = f'trestle author profile-assemble -n test_profile_a -m {md_name} -o {assembled_prof_name}'.split()
test_args = f'trestle author profile-assemble -n test_profile_a -m {md_name} -o {assembled_prof_name}'.split(
)
test_args.append('-sp')
assembled_prof_dir = tmp_trestle_dir / 'profiles/my_assembled_prof'
assembled_prof_dir.mkdir()
monkeypatch.setattr(sys, 'argv', test_args)
assert Trestle().run() == 0

Expand Down
5 changes: 5 additions & 0 deletions trestle/core/catalog/catalog_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def read_additional_content(
param_dict[const.PARAM_VALUE_ORIGIN] = param_dict[const.PROFILE_PARAM_VALUE_ORIGIN]
param_dict.pop(const.PROFILE_PARAM_VALUE_ORIGIN)
else:
# removes replace me placeholder and profile-param-value-origin as it was not modified
param_dict.pop(const.PROFILE_PARAM_VALUE_ORIGIN)
# validates param-value-origin is in dict to remove it
# because a value wasn´t provided and it shouldn´t be inheriting value from parent
if const.PARAM_VALUE_ORIGIN in param_dict:
param_dict.pop(const.PARAM_VALUE_ORIGIN)
final_param_dict[param_id] = param_dict
param_sort_map[param_id] = sort_id
new_alters: List[prof.Alter] = []
Expand Down

0 comments on commit 1c984a2

Please sign in to comment.