@@ -27,10 +27,12 @@ async def neo4j_driver():
2727@pytest_asyncio .fixture (scope = "function" )
2828async def memory (neo4j_driver ) -> Neo4jMemory :
2929 """Create a Neo4jMemory instance with the Neo4j driver."""
30- return Neo4jMemory (neo4j_driver )
30+ mem = Neo4jMemory (neo4j_driver )
31+ await mem .create_fulltext_index ()
32+ return mem
3133
3234@pytest .mark .asyncio
33- async def test_create_and_read_entities (memory ):
35+ async def test_create_and_read_entities (memory : Neo4jMemory ):
3436 # Create test entities
3537 test_entities = [
3638 Entity (name = "Alice" , type = "Person" , observations = ["Likes reading" , "Works at Company X" ]),
@@ -55,7 +57,7 @@ async def test_create_and_read_entities(memory):
5557 assert "Enjoys hiking" in entities_by_name ["Bob" ].observations
5658
5759@pytest .mark .asyncio
58- async def test_create_and_read_relations (memory ):
60+ async def test_create_and_read_relations (memory : Neo4jMemory ):
5961 # Create test entities
6062 test_entities = [
6163 Entity (name = "Alice" , type = "Person" , observations = []),
@@ -80,17 +82,17 @@ async def test_create_and_read_relations(memory):
8082 relation = graph .relations [0 ]
8183 assert relation .source == "Alice"
8284 assert relation .target == "Bob"
83- assert relation .relationType == "RELATION "
85+ assert relation .relationType == "KNOWS "
8486
8587@pytest .mark .asyncio
86- async def test_add_observations (memory ):
88+ async def test_add_observations (memory : Neo4jMemory ):
8789 # Create test entity
8890 test_entity = Entity (name = "Charlie" , type = "Person" , observations = ["Initial observation" ])
8991 await memory .create_entities ([test_entity ])
9092
9193 # Add observations
9294 observation_additions = [
93- ObservationAddition (entityName = "Charlie" , contents = ["New observation 1" , "New observation 2" ])
95+ ObservationAddition (entityName = "Charlie" , observations = ["New observation 1" , "New observation 2" ])
9496 ]
9597
9698 result = await memory .add_observations (observation_additions )
@@ -109,7 +111,7 @@ async def test_add_observations(memory):
109111 assert "New observation 2" in charlie .observations
110112
111113@pytest .mark .asyncio
112- async def test_delete_observations (memory ):
114+ async def test_delete_observations (memory : Neo4jMemory ):
113115 # Create test entity with observations
114116 test_entity = Entity (
115117 name = "Dave" ,
@@ -138,7 +140,7 @@ async def test_delete_observations(memory):
138140 assert "Observation 3" in dave .observations
139141
140142@pytest .mark .asyncio
141- async def test_delete_entities (memory ):
143+ async def test_delete_entities (memory : Neo4jMemory ):
142144 # Create test entities
143145 test_entities = [
144146 Entity (name = "Eve" , type = "Person" , observations = []),
@@ -158,7 +160,7 @@ async def test_delete_entities(memory):
158160 assert "Frank" in entity_names
159161
160162@pytest .mark .asyncio
161- async def test_delete_relations (memory ):
163+ async def test_delete_relations (memory : Neo4jMemory ):
162164 # Create test entities
163165 test_entities = [
164166 Entity (name = "Grace" , type = "Person" , observations = []),
@@ -184,10 +186,10 @@ async def test_delete_relations(memory):
184186
185187 # Verify only the WORKS_WITH relation remains
186188 assert len (graph .relations ) == 1
187- assert graph .relations [0 ].relationType == "RELATION "
189+ assert graph .relations [0 ].relationType == "WORKS_WITH "
188190
189191@pytest .mark .asyncio
190- async def test_search_nodes (memory ):
192+ async def test_search_nodes (memory : Neo4jMemory ):
191193 # Create test entities
192194 test_entities = [
193195 Entity (name = "Ian" , type = "Person" , observations = ["Likes coffee" ]),
@@ -197,7 +199,7 @@ async def test_search_nodes(memory):
197199 await memory .create_entities (test_entities )
198200
199201 # Search for coffee-related nodes
200- result = await memory .search_nodes ("coffee" )
202+ result = await memory .search_memories ("coffee" )
201203
202204 # Verify search results
203205 entity_names = [e .name for e in result .entities ]
@@ -206,18 +208,19 @@ async def test_search_nodes(memory):
206208 assert "Jane" not in entity_names
207209
208210@pytest .mark .asyncio
209- async def test_find_nodes (memory ):
211+ async def test_find_nodes (memory : Neo4jMemory ):
210212 # Create test entities
211213 test_entities = [
212214 Entity (name = "Kevin" , type = "Person" , observations = []),
213215 Entity (name = "Laura" , type = "Person" , observations = []),
214216 Entity (name = "Mike" , type = "Person" , observations = [])
215217 ]
216218 await memory .create_entities (test_entities )
217-
219+
220+
218221 # Open specific nodes
219- result = await memory .find_nodes (["Kevin" , "Laura" ])
220-
222+ result = await memory .find_memories_by_name (["Kevin" , "Laura" ])
223+
221224 # Verify only requested nodes are returned
222225 entity_names = [e .name for e in result .entities ]
223226 assert "Kevin" in entity_names
0 commit comments