Skip to content

Commit 0ec3aef

Browse files
committed
Add skeleton tests for Pinecone/Weaviate
- Needs setup on Project side
1 parent b23a91c commit 0ec3aef

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

generative_ai/rag/test_rag_examples.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
import create_corpus_example
2323
import create_corpus_feature_store_example
24+
import create_corpus_pinecone_example
2425
import create_corpus_vector_search_example
26+
import create_corpus_weaviate_example
2527
import delete_corpus_example
2628
import delete_file_example
2729
import generate_content_example
@@ -90,6 +92,20 @@ def test_create_corpus_feature_store() -> None:
9092
delete_corpus_example.delete_corpus(corpus.name)
9193

9294

95+
def test_create_corpus_pinecone() -> None:
96+
PINECONE_INDEX_NAME = "pinecone_index_name"
97+
SECRET_NAME = "rag_test_pinecone"
98+
pinecone_api_key_secret_manager_version = (
99+
f"projects/{PROJECT_ID}/secrets/{SECRET_NAME}/versions/latest"
100+
)
101+
corpus = create_corpus_pinecone_example.create_corpus_pinecone(
102+
PINECONE_INDEX_NAME,
103+
pinecone_api_key_secret_manager_version,
104+
)
105+
assert corpus
106+
delete_corpus_example.delete_corpus(corpus.name)
107+
108+
93109
def test_create_corpus_vector_search() -> None:
94110
VECTOR_SEARCH_INDEX_ID = "8048667007878430720"
95111
VECTOR_SEARCH_INDEX_ENDPOINT_ID = "8971201244047605760"
@@ -106,6 +122,22 @@ def test_create_corpus_vector_search() -> None:
106122
delete_corpus_example.delete_corpus(corpus.name)
107123

108124

125+
def test_create_corpus_weaviate() -> None:
126+
WEAVIATE_HTTP_ENDPOINT = "https://weaviate.com/xxxx"
127+
WEAVIATE_COLLECTION_NAME = "rag_engine_weaviate_test"
128+
SECRET_NAME = "rag_test_weaviate"
129+
weaviate_api_key_secret_manager_version = (
130+
f"projects/{PROJECT_ID}/secrets/{SECRET_NAME}/versions/latest"
131+
)
132+
corpus = create_corpus_weaviate_example.create_corpus_weaviate(
133+
WEAVIATE_HTTP_ENDPOINT,
134+
WEAVIATE_COLLECTION_NAME,
135+
weaviate_api_key_secret_manager_version,
136+
)
137+
assert corpus
138+
delete_corpus_example.delete_corpus(corpus.name)
139+
140+
109141
def test_get_corpus(test_corpus: pytest.fixture) -> None:
110142
retrieved_corpus = get_corpus_example.get_corpus(test_corpus.name)
111143
assert retrieved_corpus.name == test_corpus.name

0 commit comments

Comments
 (0)