Cameron's void repo torn apart for local testing
at main 25 lines 744 B view raw
1 2from memory_vector import MemoryVectorIndex 3 4 5def test_memory_vector_basic(): 6 idx = MemoryVectorIndex(embedding_dim=16) 7 idx.add('a', 'The quick brown fox') 8 idx.add('b', 'A slow turtle') 9 idx.add('c', 'Brown fox jumps high') 10 idx.build() 11 12 results = idx.search('fast brown fox', top_k=3) 13 # should return some results and 'a' or 'c' should score higher than 'b' 14 assert len(results) >= 2 15 ids = [r[0] for r in results] 16 assert 'b' in ids 17 # ensure top result is one of the fox texts 18 assert results[0][0] in ('a', 'c') 19 20 21def test_search_empty_index(): 22 idx = MemoryVectorIndex(embedding_dim=8) 23 # no build called and no entries 24 results = idx.search('anything', top_k=5) 25 assert results == []