Skip to content

Commit 7170a70

Browse files
authored
test(memory): assert S3 sidecar metadata and scope round-trip (#2840)
1 parent 12c2200 commit 7170a70

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

strands-py/tests_integ/memory/test_bedrock_knowledge_base_store.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ async def test_adds_with_scope_and_writes_a_sidecar(
290290
wait_for_indexed(kb_clients["agent"], kb_id, ds_id, {"dataSourceType": "S3", "s3": {"uri": result.document_id}})
291291

292292
entries = await store.search(marker, SearchOptions(max_search_results=10))
293-
assert any(marker in entry.content for entry in entries)
293+
match = next((entry for entry in entries if marker in entry.content), None)
294+
assert match is not None
295+
assert match.metadata is not None
296+
assert match.metadata.get("namespace") == scope
294297

295298
async def test_scope_isolates_s3_documents_from_other_scopes(
296299
self, skip_if_no_kb, bedrock_kb_context, kb_clients, cleanup_registrar
@@ -350,7 +353,7 @@ async def test_scope_isolates_s3_documents_from_other_scopes(
350353
async def test_adds_with_metadata_in_the_sidecar(
351354
self, skip_if_no_kb, bedrock_kb_context, kb_clients, cleanup_registrar
352355
):
353-
"""Caller metadata supplied to an S3 ``add`` is persisted via the sidecar, and the content stays searchable."""
356+
"""Caller metadata supplied to an S3 ``add`` round-trips through search via the sidecar."""
354357
kb_id = bedrock_kb_context.knowledge_base_id
355358
ds_id = bedrock_kb_context.s3_data_source_id
356359
bucket = bedrock_kb_context.s3_bucket
@@ -378,7 +381,11 @@ async def test_adds_with_metadata_in_the_sidecar(
378381
wait_for_indexed(kb_clients["agent"], kb_id, ds_id, {"dataSourceType": "S3", "s3": {"uri": result.document_id}})
379382

380383
entries = await store.search(marker, SearchOptions(max_search_results=10))
381-
assert any(marker in entry.content for entry in entries)
384+
match = next((entry for entry in entries if marker in entry.content), None)
385+
assert match is not None
386+
assert match.metadata is not None
387+
assert match.metadata.get("category") == "testing"
388+
assert match.metadata.get("count") == 7
382389

383390

384391
# --------------------------------------------------------------------------- #

strands-ts/test/integ/memory/bedrock-knowledge-base-store.test.node.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ describe('BedrockKnowledgeBaseStore Integration Tests', () => {
271271
})
272272

273273
const entries = await store.search(marker, { maxSearchResults: 10 })
274-
expect(entries.find((e: MemoryEntry) => e.content.includes(marker))).toBeDefined()
274+
const match = entries.find((e: MemoryEntry) => e.content.includes(marker))
275+
expect(match).toBeDefined()
276+
expect(match!.metadata?.namespace).toBe(scope)
275277
}, 60_000)
276278

277279
it('scope isolates S3 documents from other scopes', async () => {
@@ -351,7 +353,10 @@ describe('BedrockKnowledgeBaseStore Integration Tests', () => {
351353
})
352354

353355
const entries = await store.search(marker, { maxSearchResults: 10 })
354-
expect(entries.find((e: MemoryEntry) => e.content.includes(marker))).toBeDefined()
356+
const match = entries.find((e: MemoryEntry) => e.content.includes(marker))
357+
expect(match).toBeDefined()
358+
expect(match!.metadata?.category).toBe('testing')
359+
expect(match!.metadata?.count).toBe(7)
355360
}, 60_000)
356361
})
357362

0 commit comments

Comments
 (0)