From c2b1abe91b70600674d8d4e3d2c82889f9e64a27 Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 1 Mar 2024 16:01:28 -0500 Subject: [PATCH] mongodb[patch]: Set delete_many only if count_documents is not 0 (#18402) - [x] **PR message**: ***Delete this entire checklist*** and replace with - **Description:** Remove the assert statement on the `count_documents` in setup_class. It should just delete if there are documents present - **Issue:** the issue # Crashes on class setup - **Dependencies:** None - **Twitter handle:** @mongodb - [x] **Add tests and docs**: If you're adding a new integration, please include 1. N/A - [ ] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, hwchase17. Co-authored-by: Jib --- .../mongodb/tests/integration_tests/test_vectorstores.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py index d95c99ca235..8c747fb48ce 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: