Files
falyx/tests/test_completer/test_lcp_completions.py
Roland Thomas 30cb8b97b5 feat: add recursive namespace routing and standalone runner polish
- introduce namespace-aware routing with RootParseResult, RouteResult, and InvocationContext
- register submenus as FalyxNamespace entries and resolve them through _entry_map
- refactor FalyxParser to parse only root options and leave recursive routing to Falyx
- add prepare_route, resolve_route, and route dispatch flow to Falyx
- update validator and completer to understand namespace entries and route results
- unify help/TLDR rendering APIs and add custom_tldr support on Command
- tighten Command.resolve_args error handling and parser type validation
- improve CommandRunner dependency validation and argv handling
- add BottomBar.has_items and improve wrapped executor error messages
- add tests for execution options, resolve_args, command runner, and route-aware validation
2026-04-11 11:57:03 -04:00

39 lines
1.3 KiB
Python

from types import SimpleNamespace
import pytest
from prompt_toolkit.document import Document
from falyx.completer import FalyxCompleter
@pytest.fixture
def fake_falyx():
fake_arg_parser = SimpleNamespace(
suggest_next=lambda tokens, end: ["AETHERWARP", "AETHERZOOM"]
)
fake_command = SimpleNamespace(key="R", aliases=["RUN"], arg_parser=fake_arg_parser)
return SimpleNamespace(
exit_command=SimpleNamespace(key="X", aliases=["EXIT"]),
help_command=SimpleNamespace(key="H", aliases=["HELP"]),
history_command=SimpleNamespace(key="Y", aliases=["HISTORY"]),
commands={"R": fake_command},
_entry_map={"R": fake_command, "RUN": fake_command, "X": fake_command},
)
def test_lcp_completions(fake_falyx):
completer = FalyxCompleter(fake_falyx)
doc = Document("R A")
results = list(completer.get_completions(doc, None))
assert any(c.text == "AETHER" for c in results)
assert any(c.text == "AETHERWARP" for c in results)
assert any(c.text == "AETHERZOOM" for c in results)
def test_lcp_completions_space(fake_falyx):
completer = FalyxCompleter(fake_falyx)
suggestions = ["London", "New York", "San Francisco"]
stub = "N"
completions = list(completer._yield_lcp_completions(suggestions, stub))
assert any(c.text == '"New York"' for c in completions)