mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-06 12:52:04 +00:00
feat: wire semantic controls into legacy and tui v2 interfaces
This commit is contained in:
1 parent
165e2db204
commit
ec407c611a
7 files changed
+532
No files matched your search
@@ -358,3 +358,51 @@ def test_nostr_menu_dispatches_fresh_namespace(monkeypatch):
|
||||
with patch("builtins.input", side_effect=lambda *_: next(inputs)):
|
||||
main.handle_nostr_menu(pm)
|
||||
handler.assert_called_once_with(pm)
|
||||
|
||||
|
||||
def test_settings_menu_dispatches_semantic_submenu(monkeypatch):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
pm, _, _ = setup_pm(tmp_path, monkeypatch)
|
||||
inputs = iter(["18", ""])
|
||||
with patch("main.handle_semantic_index_menu") as handler:
|
||||
with patch("builtins.input", side_effect=lambda *_: next(inputs)):
|
||||
main.handle_settings(pm)
|
||||
handler.assert_called_once_with(pm)
|
||||
|
||||
|
||||
def test_semantic_submenu_search_flow(monkeypatch, capsys):
|
||||
class DummySemanticService:
|
||||
def __init__(self, _pm):
|
||||
self.last_query = None
|
||||
|
||||
def status(self):
|
||||
return {"enabled": False, "built": False, "records": 0}
|
||||
|
||||
def set_enabled(self, enabled: bool):
|
||||
return {"enabled": bool(enabled), "records": 0}
|
||||
|
||||
def build(self):
|
||||
return {"enabled": True, "built": True, "records": 2}
|
||||
|
||||
def rebuild(self):
|
||||
return {"enabled": True, "built": True, "records": 2}
|
||||
|
||||
def search(self, query: str, *, k: int = 10, kind: str | None = None):
|
||||
self.last_query = query
|
||||
return [{"entry_id": 1, "kind": "document", "label": "Doc", "score": 0.5}]
|
||||
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
pm, _, _ = setup_pm(tmp_path, monkeypatch)
|
||||
monkeypatch.setattr(main, "SemanticIndexService", DummySemanticService)
|
||||
monkeypatch.setattr(main, "pause", lambda: None)
|
||||
inputs = iter(["1", "2", "4", "6", "relay docs", ""])
|
||||
with patch("builtins.input", side_effect=lambda *_: next(inputs)):
|
||||
main.handle_semantic_index_menu(pm)
|
||||
out = capsys.readouterr().out
|
||||
assert "Status: enabled=False, built=False, records=0" in out
|
||||
assert "Semantic index enabled" in out
|
||||
assert "Semantic index built with 2 records" in out
|
||||
assert "Semantic Matches:" in out
|
||||
assert "#1 [document] Doc" in out
|
||||
Reference in new issue
Block a user