Skip to content

The agent engineering platform.

langchain-mongodb: Standardize mongodb collection/index names in tests (#18755)

Jibd60e93b6aea5
diff --git a/libs/partners/mongodb/tests/integration_tests/test_cache.py b/libs/partners/mongodb/tests/integration_tests/test_cache.py
index 52cd1dfd64..c7618c4ea2 100644
--- a/libs/partners/mongodb/tests/integration_tests/test_cache.py
+++ b/libs/partners/mongodb/tests/integration_tests/test_cache.py
@@ -13,8 +13,9 @@ from langchain_mongodb.cache import MongoDBAtlasSemanticCache, MongoDBCache
from tests.utils import ConsistentFakeEmbeddings, FakeChatModel, FakeLLM
CONN_STRING = os.environ.get("MONGODB_ATLAS_URI")
-COLLECTION = "default"
-DATABASE = "default"
+INDEX_NAME = "langchain-test-index-semantic-cache"
+DATABASE = "langchain_test_db"
+COLLECTION = "langchain_test_cache"
def random_string() -> str:
diff --git a/libs/partners/mongodb/tests/integration_tests/test_chat_message_histories.py b/libs/partners/mongodb/tests/integration_tests/test_chat_message_histories.py
index 376422afff..0454f86554 100644
--- a/libs/partners/mongodb/tests/integration_tests/test_chat_message_histories.py
+++ b/libs/partners/mongodb/tests/integration_tests/test_chat_message_histories.py
@@ -6,6 +6,9 @@ from langchain_core.messages import message_to_dict
from langchain_mongodb.chat_message_histories import MongoDBChatMessageHistory
+DATABASE = "langchain_test_db"
+COLLECTION = "langchain_test_chat"
+
# Replace these with your mongodb connection string
connection_string = os.environ.get("MONGODB_ATLAS_URI", "")
@@ -14,7 +17,10 @@ def test_memory_with_message_store() -> None:
"""Test the memory with a message store."""
# setup MongoDB as a message store
message_history = MongoDBChatMessageHistory(
- connection_string=connection_string, session_id="test-session"
+ connection_string=connection_string,
+ session_id="test-session",
+ database_name=DATABASE,
+ collection_name=COLLECTION,
)
memory = ConversationBufferMemory(
memory_key="baz", chat_memory=message_history, return_messages=True
diff --git a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py
index 8c747fb48c..b4b3fd28d4 100644
--- a/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py
+++ b/libs/partners/mongodb/tests/integration_tests/test_vectorstores.py
@@ -15,8 +15,8 @@ from pymongo.collection import Collection
from langchain_mongodb import MongoDBAtlasVectorSearch
from tests.utils import ConsistentFakeEmbeddings
-INDEX_NAME = "langchain-test-index"
-NAMESPACE = "langchain_test_db.langchain_test_collection"
+INDEX_NAME = "langchain-test-index-vectorstores"
+NAMESPACE = "langchain_test_db.langchain_test_vectorstores"
CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI")
DB_NAME, COLLECTION_NAME = NAMESPACE.split(".")
DIMENSIONS = 1536