Skip to content

Commit 6ff8235

Browse files
fixed tests
1 parent 80f12dd commit 6ff8235

File tree

14 files changed

+36
-36
lines changed

14 files changed

+36
-36
lines changed

python/samples/concepts/memory/complex_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async def cleanup(record_collection):
131131
print("Skipping deletion.")
132132
return
133133
print_with_color("Deleting collection!", Colors.CBLUE)
134-
await record_collection.delete_collection()
134+
await record_collection.ensure_collection_deleted()
135135
print_with_color("Done!", Colors.CGREY)
136136

137137

python/samples/concepts/memory/simple_memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def main():
8585
) as record_collection:
8686
# Create the collection after wiping it
8787
print_with_color("Creating test collection!", Colors.CGREY)
88-
await record_collection.delete_collection()
88+
await record_collection.ensure_collection_deleted()
8989
await record_collection.create_collection_if_not_exists()
9090

9191
# First add vectors to the records
@@ -130,7 +130,7 @@ async def main():
130130

131131
# lets cleanup!
132132
print_with_color("Deleting collection!", Colors.CBLUE)
133-
await record_collection.delete_collection()
133+
await record_collection.ensure_collection_deleted()
134134
print_with_color("Done!", Colors.CGREY)
135135

136136

python/semantic_kernel/data/vectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ async def does_collection_exist(self, collection_name: str) -> bool:
958958
except VectorStoreOperationException:
959959
return False
960960

961-
async def delete_collection(self, collection_name: str) -> None:
961+
async def ensure_collection_deleted(self, collection_name: str) -> None:
962962
"""Delete a collection.
963963
964964
This is a wrapper around the get_collection method of a collection,

python/tests/integration/memory/azure_cosmos_db/test_azure_cosmos_db_no_sql.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def test_list_collection_names(
3838
collection_names = await store.list_collection_names()
3939
assert collection_name in collection_names
4040

41-
await collection.delete_collection()
41+
await collection.ensure_collection_deleted()
4242
assert await collection.does_collection_exist() is False
4343
collection_names = await store.list_collection_names()
4444
assert collection_name not in collection_names
@@ -73,7 +73,7 @@ async def test_collection_not_created(
7373
await collection.delete(data_record["id"])
7474

7575
with pytest.raises(MemoryConnectorException, match="Container could not be deleted."):
76-
await collection.delete_collection()
76+
await collection.ensure_collection_deleted()
7777

7878
async def test_custom_partition_key(
7979
self,
@@ -109,7 +109,7 @@ async def test_custom_partition_key(
109109
assert record is None
110110

111111
# Remove collection
112-
await collection.delete_collection()
112+
await collection.ensure_collection_deleted()
113113
assert await collection.does_collection_exist() is False
114114

115115
async def test_get_include_vector(
@@ -139,7 +139,7 @@ async def test_get_include_vector(
139139
assert record is None
140140

141141
# Remove collection
142-
await collection.delete_collection()
142+
await collection.ensure_collection_deleted()
143143
assert await collection.does_collection_exist() is False
144144

145145
async def test_get_not_include_vector(
@@ -169,7 +169,7 @@ async def test_get_not_include_vector(
169169
assert record is None
170170

171171
# Remove collection
172-
await collection.delete_collection()
172+
await collection.ensure_collection_deleted()
173173
assert await collection.does_collection_exist() is False
174174

175175
async def test_collection_with_key_as_key_field(
@@ -200,7 +200,7 @@ async def test_collection_with_key_as_key_field(
200200
assert record is None
201201

202202
# Remove collection
203-
await collection.delete_collection()
203+
await collection.ensure_collection_deleted()
204204
assert await collection.does_collection_exist() is False
205205

206206
async def test_custom_client(
@@ -228,7 +228,7 @@ async def test_custom_client(
228228
collection_names = await store.list_collection_names()
229229
assert collection_name in collection_names
230230

231-
await collection.delete_collection()
231+
await collection.ensure_collection_deleted()
232232
assert await collection.does_collection_exist() is False
233233
collection_names = await store.list_collection_names()
234234
assert collection_name not in collection_names

python/tests/integration/memory/postgres/test_postgres_int.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async def test_create_does_collection_exist_and_delete(vector_store: PostgresSto
134134
does_exist_2 = await collection.does_collection_exist()
135135
assert does_exist_2 is True
136136

137-
await collection.delete_collection()
137+
await collection.ensure_collection_deleted()
138138
does_exist_3 = await collection.does_collection_exist()
139139
assert does_exist_3 is False
140140

@@ -200,7 +200,7 @@ async def test_upsert_get_and_delete_pandas(vector_store):
200200
result_after_delete = await collection.get(1)
201201
assert result_after_delete is None
202202
finally:
203-
await collection.delete_collection()
203+
await collection.ensure_collection_deleted()
204204

205205

206206
async def test_upsert_get_and_delete_batch(vector_store: PostgresStore):

python/tests/integration/memory/test_vector_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ async def test_vector_store(
458458
) as collection,
459459
):
460460
try:
461-
await collection.delete_collection()
461+
await collection.ensure_collection_deleted()
462462
except Exception as exc:
463463
logger.warning(f"Failed to delete collection: {exc}")
464464

@@ -479,7 +479,7 @@ async def test_vector_store(
479479
assert result is None
480480

481481
try:
482-
await collection.delete_collection()
482+
await collection.ensure_collection_deleted()
483483
except Exception as exc:
484484
pytest.fail(f"Failed to delete collection: {exc}")
485485
except MemoryConnectorConnectionException as exc:

python/tests/unit/connectors/memory/test_azure_ai_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ async def test_does_collection_exist(collection, mock_list_collection_names):
229229

230230

231231
async def test_delete_collection(collection, mock_delete_collection):
232-
await collection.delete_collection()
232+
await collection.ensure_collection_deleted()
233233

234234

235235
async def test_create_index_from_index(collection, mock_create_collection):
@@ -285,7 +285,7 @@ async def test_vector_store_does_collection_exists(vector_store, mock_list_colle
285285

286286
async def test_vector_store_delete_collection(vector_store, mock_delete_collection):
287287
assert vector_store.search_index_client is not None
288-
await vector_store.delete_collection("test")
288+
await vector_store.ensure_collection_deleted("test")
289289
mock_delete_collection.assert_called_once()
290290

291291

python/tests/unit/connectors/memory/test_chroma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def test_chroma_collection_create_collection(chroma_collection, mock_clien
7272

7373

7474
async def test_chroma_collection_delete_collection(chroma_collection, mock_client):
75-
await chroma_collection.delete_collection()
75+
await chroma_collection.ensure_collection_deleted()
7676
mock_client.delete_collection.assert_called_once_with(name="test_collection")
7777

7878

python/tests/unit/connectors/memory/test_faiss.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def test_create_collection_custom(store, data_model_def):
8585
assert collection.indexes["vector"] is not None
8686
assert collection.indexes["vector"] == index
8787
assert collection.indexes["vector"].is_trained is True
88-
await collection.delete_collection()
88+
await collection.ensure_collection_deleted()
8989

9090

9191
async def test_create_collection_custom_untrained(store, data_model_def):
@@ -104,7 +104,7 @@ async def test_create_collection_custom_dict(store, data_model_def):
104104
assert collection.indexes
105105
assert collection.indexes["vector"] is not None
106106
assert collection.indexes["vector"] == index
107-
await collection.delete_collection()
107+
await collection.ensure_collection_deleted()
108108

109109

110110
async def test_upsert(faiss_collection):
@@ -113,7 +113,7 @@ async def test_upsert(faiss_collection):
113113
key = await faiss_collection.upsert(record)
114114
assert key == "testid"
115115
assert faiss_collection.inner_storage == {"testid": record}
116-
await faiss_collection.delete_collection()
116+
await faiss_collection.ensure_collection_deleted()
117117

118118

119119
async def test_get(faiss_collection):
@@ -123,14 +123,14 @@ async def test_get(faiss_collection):
123123
result = await faiss_collection.get("testid")
124124
assert result["id"] == record["id"]
125125
assert result["content"] == record["content"]
126-
await faiss_collection.delete_collection()
126+
await faiss_collection.ensure_collection_deleted()
127127

128128

129129
async def test_get_missing(faiss_collection):
130130
await faiss_collection.create_collection()
131131
result = await faiss_collection.get("testid")
132132
assert result is None
133-
await faiss_collection.delete_collection()
133+
await faiss_collection.ensure_collection_deleted()
134134

135135

136136
async def test_delete(faiss_collection):
@@ -139,22 +139,22 @@ async def test_delete(faiss_collection):
139139
await faiss_collection.upsert(record)
140140
await faiss_collection.delete("testid")
141141
assert faiss_collection.inner_storage == {}
142-
await faiss_collection.delete_collection()
142+
await faiss_collection.ensure_collection_deleted()
143143

144144

145145
async def test_does_collection_exist(faiss_collection):
146146
assert await faiss_collection.does_collection_exist() is False
147147
await faiss_collection.create_collection()
148148
assert await faiss_collection.does_collection_exist() is True
149-
await faiss_collection.delete_collection()
149+
await faiss_collection.ensure_collection_deleted()
150150

151151

152152
async def test_delete_collection(faiss_collection):
153153
await faiss_collection.create_collection()
154154
record = {"id": "testid", "content": "test content", "vector": [0.1, 0.2, 0.3, 0.4, 0.5]}
155155
await faiss_collection.upsert(record)
156156
assert faiss_collection.inner_storage == {"testid": record}
157-
await faiss_collection.delete_collection()
157+
await faiss_collection.ensure_collection_deleted()
158158
assert faiss_collection.inner_storage == {}
159159

160160

@@ -178,4 +178,4 @@ async def test_create_collection_and_search(faiss_collection, dist):
178178
async for res in results.results:
179179
assert res.record == record1 if idx == 0 else record2
180180
idx += 1
181-
await faiss_collection.delete_collection()
181+
await faiss_collection.ensure_collection_deleted()

python/tests/unit/connectors/memory/test_in_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def test_delete_collection(collection):
6060
record = {"id": "testid", "content": "test content", "vector": [0.1, 0.2, 0.3, 0.4, 0.5]}
6161
await collection.upsert(record)
6262
assert collection.inner_storage == {"testid": record}
63-
await collection.delete_collection()
63+
await collection.ensure_collection_deleted()
6464
assert collection.inner_storage == {}
6565

6666

python/tests/unit/connectors/memory/test_pinecone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ async def test_create_collection_integrated(collection, mock_create_index_for_mo
196196

197197
async def test_delete_collection(collection):
198198
# Test deleting the collection
199-
await collection.delete_collection()
199+
await collection.ensure_collection_deleted()
200200
assert collection.index is None
201201
assert collection.index_client is None
202202

python/tests/unit/connectors/memory/test_qdrant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async def test_does_collection_exist(collection):
240240

241241

242242
async def test_delete_collection(collection):
243-
await collection.delete_collection()
243+
await collection.ensure_collection_deleted()
244244

245245

246246
@mark.parametrize(

python/tests/unit/connectors/memory/test_redis_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ async def test_does_collection_exist_false(collection_hash, mock_does_collection
287287

288288

289289
async def test_delete_collection(collection_hash, mock_delete_collection):
290-
await collection_hash.delete_collection()
291-
await collection_hash.delete_collection()
290+
await collection_hash.ensure_collection_deleted()
291+
await collection_hash.ensure_collection_deleted()
292292

293293

294294
async def test_create_index(collection_hash, mock_create_collection):

python/tests/unit/data/test_vector_store_record_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ async def test_collection_operations(vector_store_record_collection):
6363
record = {"id": "id", "content": "test_content", "vector": [1.0, 2.0, 3.0]}
6464
await vector_store_record_collection.upsert(record)
6565
assert len(vector_store_record_collection.inner_storage) == 1
66-
await vector_store_record_collection.delete_collection()
66+
await vector_store_record_collection.ensure_collection_deleted()
6767
assert vector_store_record_collection.inner_storage == {}
68-
await vector_store_record_collection.create_collection_if_not_exists()
68+
await vector_store_record_collection.ensure_collection_exists()
6969

7070

7171
async def test_collection_create_if_not_exists(DictVectorStoreRecordCollection, definition):
@@ -77,7 +77,7 @@ async def test_collection_create_if_not_exists(DictVectorStoreRecordCollection,
7777
record_type=dict,
7878
definition=definition,
7979
)
80-
await vector_store_record_collection.create_collection_if_not_exists()
80+
await vector_store_record_collection.ensure_collection_exists()
8181
create_mock.assert_called_once()
8282

8383

@@ -276,7 +276,7 @@ async def test_get_fail_multiple(DictVectorStoreRecordCollection, definition):
276276
await vector_store_record_collection.upsert(record)
277277
assert len(vector_store_record_collection.inner_storage) == 1
278278
with (
279-
patch("semantic_kernel.data.vector_storage.VectorStoreRecordCollection.deserialize") as deserialize_mock,
279+
patch("semantic_kernel.data.vectors.VectorStoreRecordCollection.deserialize") as deserialize_mock,
280280
raises(
281281
VectorStoreModelDeserializationException, match="Error deserializing record, multiple records returned:"
282282
),

0 commit comments

Comments
 (0)