Skip to content

[langchain-db2] Update integration tests suite #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions libs/langchain-db2/tests/integration_tests/test_db2vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import threading
import time

import pytest
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_community.vectorstores.utils import DistanceStrategy

Expand All @@ -27,12 +28,12 @@ def test_table_exists_test() -> None:
try:
import ibm_db_dbi # type: ignore
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MateuszOssGit. I set it to return before because on the machine with no ibm_db_dbi and no connection to db2, the this testcase is not able to run. I think the integration test relies on the ibm_db_dbi and the connection to db2. Not sure if the integration test in the CI pipeline can pass if you change them like this.


try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")

# 1. Create a Table
_create_table(connection, "TB1", 8148)
Expand Down Expand Up @@ -94,12 +95,12 @@ def test_create_table_test() -> None:
try:
import ibm_db_dbi
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")

try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")

# 1. New table - HELLO
# Dimension - 100
Expand Down Expand Up @@ -230,12 +231,12 @@ def test_add_texts_test() -> None:
try:
import ibm_db_dbi
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")

try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")

# 1. Add 2 records to table
# Expectation: Successful
Expand Down Expand Up @@ -397,12 +398,12 @@ def test_embed_documents_test() -> None:
try:
import ibm_db_dbi
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")

try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")
# 1. Embed String Example-'Sam'
# Expectation: Successful.
model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
Expand All @@ -428,12 +429,12 @@ def test_embed_query_test() -> None:
try:
import ibm_db_dbi
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")

try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")

# 1. Embed String
# Expectation: Successful.
Expand All @@ -456,12 +457,12 @@ def test_perform_search_test() -> None:
try:
import ibm_db_dbi
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")

try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")

model1 = HuggingFaceEmbeddings(
model_name="sentence-transformers/paraphrase-mpnet-base-v2"
Expand Down Expand Up @@ -522,12 +523,12 @@ def test_get_pks() -> None:
try:
import ibm_db_dbi # type: ignore
except ImportError:
return
pytest.fail("ibm_db_dbi package is required to run this test")

try:
connection = ibm_db_dbi.connect(database, username, password)
except Exception:
return
except Exception as e:
pytest.fail(f"Could not connect to IBM DB2: {e!s}")

model = HuggingFaceEmbeddings(
model_name="sentence-transformers/paraphrase-mpnet-base-v2"
Expand Down