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 <jib@byblack.us>
pull/18404/head
Jib 7 months ago committed by GitHub
parent c9153a3fd4
commit c2b1abe91b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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:

Loading…
Cancel
Save