Skip to content

Commit 3913e40

Browse files
authored
INTPYTHON-780 Make TestMongoDBAtlasFullTextSearchRetriever more robust (#228)
1 parent 127e2f9 commit 3913e40

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

libs/langchain-mongodb/tests/integration_tests/test_retrievers_standard.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ def setup_test(coll: Collection) -> MongoDBAtlasVectorSearch:
4646
text_key=PAGE_CONTENT_FIELD,
4747
auto_index_timeout=TIMEOUT,
4848
)
49-
coll.delete_many({})
50-
51-
vs.add_documents(
52-
[
53-
Document(page_content="In 2023, I visited Paris"),
54-
Document(page_content="In 2022, I visited New York"),
55-
Document(page_content="In 2021, I visited New Orleans"),
56-
Document(page_content="Sandwiches are beautiful. Sandwiches are fine."),
57-
]
58-
)
49+
50+
if coll.count_documents({}) == 0:
51+
vs.add_documents(
52+
[
53+
Document(page_content="In 2023, I visited Paris"),
54+
Document(page_content="In 2022, I visited New York"),
55+
Document(page_content="In 2021, I visited New Orleans"),
56+
Document(page_content="Sandwiches are beautiful. Sandwiches are fine."),
57+
]
58+
)
5959

6060
# Set up the search index if needed.
6161
if not any([ix["name"] == SEARCH_INDEX_NAME for ix in coll.list_search_indexes()]):

0 commit comments

Comments
 (0)