Skip to content

Commit

Permalink
Merge pull request #23 from Safe/transformer-hyphen-help
Browse files Browse the repository at this point in the history
Correct transformer help alias generation for hyphenated package uids <cyl>
  • Loading branch information
Heather Li authored and GitHub Enterprise committed Jun 23, 2023
2 parents df97e5c + f00983a commit f81f780
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# fme-packager changes

# 1.4.4

* Improve help validation for packages with hyphenated UIDs.

# 1.4.3

* Improve verify command
Expand Down
2 changes: 1 addition & 1 deletion fme_packager/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.3"
__version__ = "1.4.4"
5 changes: 3 additions & 2 deletions fme_packager/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ def get_expected_help_index(fpkg_metadata: FMEPackageMetadata, format_directions
index = {}
if not format_directions:
format_directions = {}
# dashes in the UIDs get turned to underscores
fpkg_ident = f"{fpkg_metadata.publisher_uid}_{fpkg_metadata.uid}".replace("-", "_")
fpkg_ident = f"{fpkg_metadata.publisher_uid}_{fpkg_metadata.uid}"
# Each transformer has only one topic.
for xformer in fpkg_metadata.transformers:
index[f"fmx_{fpkg_ident}_{xformer.name}"] = f"/{xformer.name}.htm"
# Each format has many topics.
for fmt in fpkg_metadata.formats:
# dashes in the UIDs get turned to underscores when looking for format help
fpkg_ident = fpkg_ident.replace("-", "_")
fmt_ident = f"{fpkg_ident}_{fmt.name}".lower()
directions = format_directions.get(fmt.name, "rw")
# Format prefix is "rw" even when read-only or write-only
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/help/htm/package_help.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fmx_example_package_Transformer,/Transformers/Transformer-pkg.htm
fmx_example_package-hyphen_Transformer,/Transformers/Transformer-pkg.htm
36 changes: 18 additions & 18 deletions tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def mock_metadata():
return FMEPackageMetadata(
{
"uid": "package",
"uid": "package-hyphen",
"publisher_uid": "example",
"package_content": {"transformers": [{"name": "Transformer", "version": 1}]},
}
Expand All @@ -22,35 +22,35 @@ def mock_metadata():

def test_get_expected_help_contexts_transformer(mock_metadata):
assert get_expected_help_index(mock_metadata) == {
"fmx_example_package_Transformer": "/Transformer.htm"
"fmx_example_package-hyphen_Transformer": "/Transformer.htm"
}


def test_get_expected_help_contexts_format():
metadata = FMEPackageMetadata(
{
"uid": "package",
"uid": "package-hyphen",
"publisher_uid": "example",
"package_content": {"formats": [{"name": "demoformat"}]},
}
)
assert get_expected_help_index(metadata) == {
"ft_example_package_demoformat_param_r": "/demoformat_ft_param_r.htm",
"ft_example_package_demoformat_param_w": "/demoformat_ft_param_w.htm",
"ft_example_package_demoformat_user_attr": "/demoformat_ft_user_attr.htm",
"param_example_package_demoformat_r": "/demoformat_param_r.htm",
"param_example_package_demoformat_w": "/demoformat_param_w.htm",
"rw_example_package_demoformat_feature_rep": "/demoformat_feature_rep.htm",
"rw_example_package_demoformat_index": "/demoformat.htm",
"ft_example_package_hyphen_demoformat_param_r": "/demoformat_ft_param_r.htm",
"ft_example_package_hyphen_demoformat_param_w": "/demoformat_ft_param_w.htm",
"ft_example_package_hyphen_demoformat_user_attr": "/demoformat_ft_user_attr.htm",
"param_example_package_hyphen_demoformat_r": "/demoformat_param_r.htm",
"param_example_package_hyphen_demoformat_w": "/demoformat_param_w.htm",
"rw_example_package_hyphen_demoformat_feature_rep": "/demoformat_feature_rep.htm",
"rw_example_package_hyphen_demoformat_index": "/demoformat.htm",
}
assert sorted(get_expected_help_index(metadata)) == [
"ft_example_package_demoformat_param_r",
"ft_example_package_demoformat_param_w",
"ft_example_package_demoformat_user_attr",
"param_example_package_demoformat_r",
"param_example_package_demoformat_w",
"rw_example_package_demoformat_feature_rep",
"rw_example_package_demoformat_index",
"ft_example_package_hyphen_demoformat_param_r",
"ft_example_package_hyphen_demoformat_param_w",
"ft_example_package_hyphen_demoformat_user_attr",
"param_example_package_hyphen_demoformat_r",
"param_example_package_hyphen_demoformat_w",
"rw_example_package_hyphen_demoformat_feature_rep",
"rw_example_package_hyphen_demoformat_index",
]


Expand Down Expand Up @@ -101,4 +101,4 @@ def test_md(mock_metadata, tmp_path):
index_file = tmp_path / "package_help.csv"
assert index_file.is_file()
with index_file.open("r") as f:
assert f.read() == "fmx_example_package_Transformer,/Transformer.htm\n"
assert f.read() == "fmx_example_package-hyphen_Transformer,/Transformer.htm\n"

0 comments on commit f81f780

Please sign in to comment.