Skip to content

The agent engineering platform.

mongodb[patch]: Set delete_many only if count_documents is not 0 (#18402)

Jibc2b1abe91b70
diff --git a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py
index d95c99ca23..8c747fb48c 100644
--- a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py
+++ b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py
@@ -50,7 +50,8 @@ class TestMongoDBAtlasVectorSearch:
def setup_class(cls) -> None:
# insure the test collection is empty
collection = get_collection()
- assert collection.count_documents({}) == 0 # type: ignore[index] # noqa: E501
+ if collection.count_documents({}):
+ collection.delete_many({}) # type: ignore[index] # noqa: E501
@classmethod
def teardown_class(cls) -> None: