Skip to content

Commit

Permalink
chore: refactor rag sdk preview tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 700224513
  • Loading branch information
vertex-sdk-bot authored and copybara-github committed Nov 26, 2024
1 parent 7cbda03 commit 6d43ad3
Show file tree
Hide file tree
Showing 5 changed files with 1,609 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/unit/vertex_rag/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,11 +22,13 @@
VertexRagDataServiceAsyncClient,
VertexRagDataServiceClient,
)
import test_rag_constants as tc
import test_rag_constants_preview
import mock
import pytest


# -*- coding: utf-8 -*-

_TEST_CREDENTIALS = mock.Mock(spec=auth_credentials.AnonymousCredentials())


Expand All @@ -37,7 +37,7 @@ def google_auth_mock():
with mock.patch.object(auth, "default") as auth_mock:
auth_mock.return_value = (
auth_credentials.AnonymousCredentials(),
tc.TEST_PROJECT,
test_rag_constants_preview.TEST_PROJECT,
)
yield auth_mock

Expand All @@ -59,13 +59,17 @@ def rag_data_client_mock():
api_client_mock = mock.Mock(spec=VertexRagDataServiceClient)

# get_rag_corpus
api_client_mock.get_rag_corpus.return_value = tc.TEST_GAPIC_RAG_CORPUS
api_client_mock.get_rag_corpus.return_value = (
test_rag_constants_preview.TEST_GAPIC_RAG_CORPUS
)
# delete_rag_corpus
delete_rag_corpus_lro_mock = mock.Mock(ga_operation.Operation)
delete_rag_corpus_lro_mock.result.return_value = DeleteRagCorpusRequest()
api_client_mock.delete_rag_corpus.return_value = delete_rag_corpus_lro_mock
# get_rag_file
api_client_mock.get_rag_file.return_value = tc.TEST_GAPIC_RAG_FILE
api_client_mock.get_rag_file.return_value = (
test_rag_constants_preview.TEST_GAPIC_RAG_FILE
)

rag_data_client_mock.return_value = api_client_mock
yield rag_data_client_mock
Expand Down
Loading

0 comments on commit 6d43ad3

Please sign in to comment.