mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-29 18:46:59 +00:00
Fix session search test double filters
This commit is contained in:
parent
cb00495551
commit
eb087b3089
1 changed files with 40 additions and 5 deletions
|
|
@ -14,10 +14,29 @@ class _FakeSessionDB:
|
|||
|
||||
closed = False
|
||||
|
||||
def search_sessions_by_id(self, query, limit=20, include_archived=True):
|
||||
@staticmethod
|
||||
def _source_allowed(row, source=None, sources=None, exclude_sources=None):
|
||||
row_source = row.get("source")
|
||||
if source and row_source != source:
|
||||
return False
|
||||
if sources and row_source not in sources:
|
||||
return False
|
||||
if exclude_sources and row_source in exclude_sources:
|
||||
return False
|
||||
return True
|
||||
|
||||
def search_sessions_by_id(
|
||||
self,
|
||||
query,
|
||||
limit=20,
|
||||
include_archived=True,
|
||||
source=None,
|
||||
sources=None,
|
||||
exclude_sources=None,
|
||||
):
|
||||
assert query == "20260603"
|
||||
assert include_archived is True
|
||||
return [
|
||||
rows = [
|
||||
{
|
||||
"id": "20260603_090200_exact",
|
||||
"preview": "ID match preview",
|
||||
|
|
@ -26,10 +45,17 @@ class _FakeSessionDB:
|
|||
"started_at": 100,
|
||||
}
|
||||
]
|
||||
|
||||
def search_messages(self, query, limit=20):
|
||||
assert query == "20260603*"
|
||||
return [
|
||||
row
|
||||
for row in rows
|
||||
if self._source_allowed(
|
||||
row, source=source, sources=sources, exclude_sources=exclude_sources
|
||||
)
|
||||
][:limit]
|
||||
|
||||
def search_messages(self, query, source_filter=None, exclude_sources=None, limit=20):
|
||||
assert query == "20260603*"
|
||||
rows = [
|
||||
{
|
||||
"session_id": "20260603_090200_exact",
|
||||
"snippet": "duplicate content hit should not replace ID hit",
|
||||
|
|
@ -47,6 +73,13 @@ class _FakeSessionDB:
|
|||
"session_started": 200,
|
||||
},
|
||||
]
|
||||
return [
|
||||
row
|
||||
for row in rows
|
||||
if self._source_allowed(
|
||||
row, sources=source_filter, exclude_sources=exclude_sources
|
||||
)
|
||||
][:limit]
|
||||
|
||||
def get_session(self, session_id):
|
||||
# No compression chains in this fixture — every session is its own root.
|
||||
|
|
@ -69,6 +102,7 @@ def test_desktop_session_search_merges_id_matches_before_content_matches(monkeyp
|
|||
assert response == {
|
||||
"results": [
|
||||
{
|
||||
"id": "20260603_090200_exact",
|
||||
"session_id": "20260603_090200_exact",
|
||||
"lineage_root": "20260603_090200_exact",
|
||||
"snippet": "ID match preview",
|
||||
|
|
@ -78,6 +112,7 @@ def test_desktop_session_search_merges_id_matches_before_content_matches(monkeyp
|
|||
"session_started": 100,
|
||||
},
|
||||
{
|
||||
"id": "content_session",
|
||||
"session_id": "content_session",
|
||||
"lineage_root": "content_session",
|
||||
"snippet": "content hit",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue