Skip to content

Commit 57b012c

Browse files
committed
refactor: add more unit tests and refactor
1 parent 0139c0f commit 57b012c

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

models/tests/test_openai.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa: F401
3+
# pylint: disable=too-few-public-methods
4+
"""
5+
Test integrity of base class.
6+
"""
7+
import pytest # pylint: disable=unused-import
8+
9+
from ..ssm import SalesSupportModel
10+
11+
12+
class TestOpenAI:
13+
"""Test SalesSupportModel class."""
14+
15+
def test_03_test_openai_connectivity(self):
16+
"""Ensure that we have connectivity to OpenAI."""
17+
18+
ssm = SalesSupportModel()
19+
retval = ssm.cached_chat_request(
20+
"your are a helpful assistant", "please return the value 'CORRECT' in all upper case."
21+
)
22+
assert retval == "CORRECT"

models/tests/test_pinecone.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa: F401
3+
"""
4+
Test integrity of base class.
5+
"""
6+
7+
import pinecone
8+
import pytest # pylint: disable=unused-import
9+
from langchain.embeddings import OpenAIEmbeddings
10+
from langchain.vectorstores.pinecone import Pinecone
11+
12+
from ..const import Credentials
13+
14+
15+
class TestPinecone:
16+
"""Test SalesSupportModel class."""
17+
18+
def test_01_test_pinecone_connectivity(self):
19+
"""Ensure that we have connectivity to Pinecone."""
20+
# pylint: disable=broad-except
21+
try:
22+
pinecone.init(api_key=Credentials.PINECONE_API_KEY, environment=Credentials.PINECONE_ENVIRONMENT)
23+
except Exception as e:
24+
assert False, f"pinecone.init() failed with exception: {e}"
25+
26+
def test_02_test_pinecone_index(self):
27+
"""Ensure that the Pinecone index exists and that we can connect to it."""
28+
pinecone.init(api_key=Credentials.PINECONE_API_KEY, environment=Credentials.PINECONE_ENVIRONMENT)
29+
openai_embedding = OpenAIEmbeddings()
30+
31+
# pylint: disable=broad-except
32+
try:
33+
Pinecone.from_existing_index(
34+
Credentials.PINECONE_INDEX_NAME,
35+
embedding=openai_embedding,
36+
)
37+
except Exception as e:
38+
assert (
39+
False
40+
), f"Pinecone initialization of index {Credentials.PINECONE_INDEX_NAME,} failed with exception: {e}"

models/tests/test_prompts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# flake8: noqa: F401
3-
# pylint: disable=too-few-public-methods
43
"""
54
Test integrity of base class.
65
"""

models/tests/test_ssm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# flake8: noqa: F401
3-
# pylint: disable=too-few-public-methods
43
"""
54
Test integrity of base class.
65
"""

0 commit comments

Comments
 (0)