Skip to content

Commit

Permalink
Render placeholders in menu_name (#175)
Browse files Browse the repository at this point in the history
* render 'menu_name' keys too

* add test

* tests use base_prefix

* only test start menu

* skip test if non-windows

* try again

* pre-commit

* debug

* try again

* do remove in check_output

* parent

* break

* add news
  • Loading branch information
jaimergp authored Jan 11, 2024
1 parent 9b8c0a1 commit 5e4e8e7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion menuinst/platforms/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def start_menu_location(self) -> Path:
In this property we only report the path to the Start menu.
For other menus, check their respective properties.
"""
return Path(windows_folder_path(self.mode, False, "start")) / self.name
return Path(windows_folder_path(self.mode, False, "start")) / self.render(self.name)

@property
def quick_launch_location(self) -> Path:
Expand Down
19 changes: 19 additions & 0 deletions news/175-render-menu-name
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Render placeholders in `menu_name` key. (#175)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
2 changes: 1 addition & 1 deletion tests/data/jsons/sys-prefix.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://schemas.conda.io/menuinst-1.schema.json",
"menu_name": "Sys.Prefix",
"menu_name": "Sys.Prefix {{ DISTRIBUTION_NAME }}",
"menu_items": [
{
"name": "Sys.Prefix",
Expand Down
25 changes: 20 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,28 @@ def check_output_from_shortcut(
if expected_output is not None:
assert output.strip() == expected_output

return abs_json_path, paths, output
return abs_json_path, paths, tmp_base_path, output


def test_install_prefix(delete_files):
check_output_from_shortcut(delete_files, "sys-prefix.json", expected_output=sys.prefix)


@pytest.mark.skipif(PLATFORM != "win", reason="Windows only")
def test_placeholders_in_menu_name(delete_files):
_, paths, tmp_base_path, _ = check_output_from_shortcut(
delete_files,
"sys-prefix.json",
expected_output=sys.prefix,
)
for path in paths:
if path.suffix == ".lnk" and "Start Menu" in path.parts:
assert path.parent.name == f"Sys.Prefix {Path(tmp_base_path).name}"
break
else:
raise AssertionError("Didn't find Start Menu")


def test_precommands(delete_files):
check_output_from_shortcut(
delete_files, "precommands.json", expected_output="rhododendron and bees"
Expand All @@ -150,7 +165,7 @@ def test_precommands(delete_files):

@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
def test_entitlements(delete_files):
json_path, paths, _ = check_output_from_shortcut(
json_path, paths, *_ = check_output_from_shortcut(
delete_files, "entitlements.json", remove_after=False, expected_output="entitlements"
)
# verify signature
Expand Down Expand Up @@ -182,7 +197,7 @@ def test_entitlements(delete_files):

@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
def test_no_entitlements_no_signature(delete_files):
json_path, paths, _ = check_output_from_shortcut(
json_path, paths, *_ = check_output_from_shortcut(
delete_files, "sys-prefix.json", remove_after=False, expected_output=sys.prefix
)
app_dir = next(p for p in paths if p.name.endswith(".app"))
Expand All @@ -198,7 +213,7 @@ def test_no_entitlements_no_signature(delete_files):

@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
def test_info_plist(delete_files):
json_path, paths, _ = check_output_from_shortcut(
json_path, paths, *_ = check_output_from_shortcut(
delete_files, "entitlements.json", remove_after=False, expected_output="entitlements"
)
app_dir = next(p for p in paths if p.name.endswith(".app"))
Expand All @@ -217,7 +232,7 @@ def test_info_plist(delete_files):

@pytest.mark.skipif(PLATFORM != "osx", reason="macOS only")
def test_osx_symlinks(delete_files):
json_path, paths, output = check_output_from_shortcut(
json_path, paths, _, output = check_output_from_shortcut(
delete_files, "osx_symlinks.json", remove_after=False
)
app_dir = next(p for p in paths if p.name.endswith(".app"))
Expand Down

0 comments on commit 5e4e8e7

Please sign in to comment.