griptape
54 строки · 2.3 Кб
1import pytest2import os3from tests.utils.structure_tester import StructureTester4
5
6class TestGoogleDriveClient:7@pytest.fixture(8autouse=True,9params=StructureTester.TOOLKIT_TASK_CAPABLE_PROMPT_DRIVERS,10ids=StructureTester.prompt_driver_id_fn,11)12def structure_tester(self, request):13from griptape.structures import Agent14from griptape.tools import GoogleDriveClient15
16return StructureTester(17Agent(18tools=[19GoogleDriveClient(20off_prompt=False,21service_account_credentials={22"type": os.environ["GOOGLE_ACCOUNT_TYPE"],23"project_id": os.environ["GOOGLE_PROJECT_ID"],24"private_key_id": os.environ["GOOGLE_PRIVATE_KEY_ID"],25"private_key": os.environ["GOOGLE_PRIVATE_KEY"],26"client_email": os.environ["GOOGLE_CLIENT_EMAIL"],27"client_id": os.environ["GOOGLE_CLIENT_ID"],28"auth_uri": "https://accounts.google.com/o/oauth2/auth",29"token_uri": "https://oauth2.googleapis.com/token",30"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",31"client_x509_cert_url": os.environ["GOOGLE_CERT_URL"],32},33owner_email=os.environ["GOOGLE_OWNER_EMAIL"],34)35],36prompt_driver=request.param,37conversation_memory=None,38)39)40
41def test_list_files(self, structure_tester):42structure_tester.run("List all files on Google Drive.")43
44def test_download_file(self, structure_tester):45structure_tester.run('Download the file called "sample1.txt" from Google Drive.')46
47def test_save_content(self, structure_tester):48structure_tester.run('Save content "Hello, Google Drive!" on Google Drive as "hello.txt".')49
50def test_search_files_by_name(self, structure_tester):51structure_tester.run('Search files with name "hello.txt" on Google Drive.')52
53def test_search_files_by_content(self, structure_tester):54structure_tester.run('Search files with content "Hello, Google Drive!" on Google Drive.')55