Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cogent3/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _make_types(app) -> dict:
return _types


def available_apps():
def available_apps(app_name_filter: str | None = None):
"""returns Table listing the available apps"""
from cogent3.util.table import Table

Expand All @@ -68,6 +68,9 @@ def available_apps():
if any(app.startswith(d) for d in deprecated):
continue

if app_name_filter and app_name_filter not in app:
continue

with contextlib.suppress(AttributeError):
# probably a local scope issue in testing!
rows.append(_get_app_attr(app, is_comp))
Expand Down
9 changes: 9 additions & 0 deletions tests/test_app/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,14 @@ def test_app_help_signature(capsys, app_name):
assert got.count("\n") > 1


def test_available_apps_filter():
"""available apps can be filtered by name"""
app_name_filter: str = "load"
filtered_apps = available_apps(app_name_filter)
assert isinstance(filtered_apps, Table)
assert len(filtered_apps) > 0
# check every returned table row 'name' has filter in it
assert sum(app_name_filter in n for n in filtered_apps.columns["name"]) == len(filtered_apps)

if __name__ == "__main__":
main()