18
18
)
19
19
from tests .utils import VECTORSTORE_CONNECTION_STRING_ASYNCPG as CONNECTION_STRING
20
20
21
- DEFAULT_TABLE = "default" + str (uuid .uuid4 ()).replace ("-" , "_" )
22
- DEFAULT_INDEX_NAME = DEFAULT_TABLE + "index"
21
+ uuid_str = str (uuid .uuid4 ()).replace ("-" , "_" )
22
+ DEFAULT_TABLE = "default" + uuid_str
23
+ DEFAULT_INDEX_NAME = uuid_str + "index"
23
24
VECTOR_SIZE = 768
24
25
25
26
embeddings_service = DeterministicFakeEmbedding (size = VECTOR_SIZE )
@@ -67,14 +68,14 @@ async def vs(self, engine: PGEngine) -> AsyncIterator[AsyncPGVectorStore]:
67
68
)
68
69
69
70
await vs .aadd_texts (texts , ids = ids )
70
- await vs .adrop_vector_index ()
71
+ await vs .adrop_vector_index (DEFAULT_INDEX_NAME )
71
72
yield vs
72
73
73
74
async def test_aapply_vector_index (self , vs : AsyncPGVectorStore ) -> None :
74
75
index = HNSWIndex ()
75
76
await vs .aapply_vector_index (index )
76
77
assert await vs .is_valid_index (DEFAULT_INDEX_NAME )
77
- await vs .adrop_vector_index ()
78
+ await vs .adrop_vector_index (DEFAULT_INDEX_NAME )
78
79
79
80
async def test_areindex (self , vs : AsyncPGVectorStore ) -> None :
80
81
if not await vs .is_valid_index (DEFAULT_INDEX_NAME ):
@@ -86,7 +87,7 @@ async def test_areindex(self, vs: AsyncPGVectorStore) -> None:
86
87
await vs .adrop_vector_index (DEFAULT_INDEX_NAME )
87
88
88
89
async def test_dropindex (self , vs : AsyncPGVectorStore ) -> None :
89
- await vs .adrop_vector_index ()
90
+ await vs .adrop_vector_index (DEFAULT_INDEX_NAME )
90
91
result = await vs .is_valid_index (DEFAULT_INDEX_NAME )
91
92
assert not result
92
93
@@ -101,7 +102,7 @@ async def test_aapply_vector_index_ivfflat(self, vs: AsyncPGVectorStore) -> None
101
102
await vs .aapply_vector_index (index )
102
103
assert await vs .is_valid_index ("secondindex" )
103
104
await vs .adrop_vector_index ("secondindex" )
104
- await vs .adrop_vector_index ()
105
+ await vs .adrop_vector_index (DEFAULT_INDEX_NAME )
105
106
106
107
async def test_is_valid_index (self , vs : AsyncPGVectorStore ) -> None :
107
108
is_valid = await vs .is_valid_index ("invalid_index" )
0 commit comments