From 1ccef6606ee07b1ce355ef0a13b96201e5f40d3b Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Thu, 26 Oct 2023 15:23:20 -0400 Subject: [PATCH] fix(entrypoint): fixes top level ModelFilter logic Replace "." with "*" for include all logic Adds tests to ModelFilter to validate Signed-off-by: Jennifer Power --- tests/trestlebot/tasks/test_assemble_task.py | 2 +- tests/trestlebot/tasks/test_base_task.py | 9 +++++---- tests/trestlebot/tasks/test_regenerate_task.py | 2 +- trestlebot/entrypoints/autosync.py | 2 +- trestlebot/entrypoints/rule_transform.py | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/trestlebot/tasks/test_assemble_task.py b/tests/trestlebot/tasks/test_assemble_task.py index 5c3bfa80..ad963dc2 100644 --- a/tests/trestlebot/tasks/test_assemble_task.py +++ b/tests/trestlebot/tasks/test_assemble_task.py @@ -96,7 +96,7 @@ def test_assemble_task_with_skip(tmp_trestle_dir: str, skip_list: List[str]) -> mock = Mock(spec=AuthorObjectBase) - filter = ModelFilter(skip_list, ["."]) + filter = ModelFilter(skip_list, ["*"]) assemble_task = AssembleTask( working_dir=tmp_trestle_dir, diff --git a/tests/trestlebot/tasks/test_base_task.py b/tests/trestlebot/tasks/test_base_task.py index b2887c3c..d696e6e6 100644 --- a/tests/trestlebot/tasks/test_base_task.py +++ b/tests/trestlebot/tasks/test_base_task.py @@ -29,18 +29,19 @@ [ [["simplified_nist_catalog"], [], "simplified_nist_catalog", True], [[], ["simplified_nist_catalog"], "simplified_nist_catalog", False], - [["simplified*"], ["."], "simplified_nist_catalog", True], + [["simplified*"], ["*"], "simplified_nist_catalog", True], [ ["simplified_nist_catalog"], ["simplified*"], "simplified_nist_profile", False, ], + [[], [], "simplified_nist_catalog", True], + [[], ["*"], "simplified_nist_catalog", False] ], ) -def test_is_skipped( - skip_list: List[str], include_list: List[str], model_name: str, expected: str -) -> None: +def test_is_skipped(skip_list: List[str], include_list: List[str], + model_name: str, expected: str) -> None: """Test skip logic.""" model_path = pathlib.Path(model_name) model_filter = ModelFilter(skip_list, include_list) diff --git a/tests/trestlebot/tasks/test_regenerate_task.py b/tests/trestlebot/tasks/test_regenerate_task.py index 6000b107..4da542ec 100644 --- a/tests/trestlebot/tasks/test_regenerate_task.py +++ b/tests/trestlebot/tasks/test_regenerate_task.py @@ -87,7 +87,7 @@ def test_regenerate_task_with_skip(tmp_trestle_dir: str, skip_list: List[str]) - mock = Mock(spec=AuthorObjectBase) - filter = ModelFilter(skip_list, ["."]) + filter = ModelFilter(skip_list, ["*"]) regenerate_task = RegenerateTask( working_dir=tmp_trestle_dir, diff --git a/trestlebot/entrypoints/autosync.py b/trestlebot/entrypoints/autosync.py index 3f638976..36fe0053 100644 --- a/trestlebot/entrypoints/autosync.py +++ b/trestlebot/entrypoints/autosync.py @@ -122,7 +122,7 @@ def run(self, args: argparse.Namespace) -> None: filter: ModelFilter = ModelFilter( skip_patterns=comma_sep_to_list(args.skip_items), - include_patterns=["."], + include_patterns=["*"], ) # Assuming an edit has occurred assemble would be run before regenerate. diff --git a/trestlebot/entrypoints/rule_transform.py b/trestlebot/entrypoints/rule_transform.py index 15eee2e8..df197ffd 100644 --- a/trestlebot/entrypoints/rule_transform.py +++ b/trestlebot/entrypoints/rule_transform.py @@ -65,7 +65,7 @@ def run(self, args: argparse.Namespace) -> None: filter: ModelFilter = ModelFilter( skip_patterns=comma_sep_to_list(args.skip_items), - include_patterns=["."], + include_patterns=["*"], ) rule_transform_task: RuleTransformTask = RuleTransformTask(