personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4import pytest
5
6from solstone.think.indexer.journal import (
7 scan_journal,
8 search_entities,
9)
10
11
12@pytest.fixture(autouse=True)
13def indexed_journal(journal_copy):
14 scan_journal(str(journal_copy), full=True)
15
16
17class TestSearchEntities:
18 def test_by_type_person(self):
19 results = search_entities(entity_type="Person")
20 assert isinstance(results, list)
21 for r in results:
22 assert r["type"] == "Person"
23
24 def test_by_type_company(self):
25 results = search_entities(entity_type="Company")
26 for r in results:
27 assert r["type"] == "Company"
28
29 def test_by_facet(self):
30 results = search_entities(facet="work")
31 assert isinstance(results, list)
32
33 def test_by_query(self):
34 results = search_entities(query="Alice")
35 assert isinstance(results, list)
36 assert any(r["name"] in {"Alice Johnson", "Alice"} for r in results)
37
38 def test_all_entities(self):
39 results = search_entities()
40 assert isinstance(results, list)
41 assert len(results) > 0
42
43 def test_result_structure(self):
44 results = search_entities()
45 if results:
46 r = results[0]
47 assert "entity_id" in r
48 assert "name" in r
49 assert "type" in r
50
51 def test_limit(self):
52 results = search_entities(limit=3)
53 assert len(results) <= 3