You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running pytest -v in a local virtualenv on the test_main.py files:
genai_api/src/test_main.py fails when running pytest because the OS environment variables are not in place.
api/vertex_*/src/test_main.py fail when running pytest because there is no mock for Google_Cloud_GenAI, so the test tries to connect to a real project and call a LLM in that project.
api/vertex_*/src/test_main.py do not have the correct expected_response since they return a single text string response.text and not a json object {'mocked_key': 'mocked_value'}.
What you expected to happen:
Running the unit tests should not require setting up environment variables or calls to an external service.
How to reproduce it (as minimally and precisely as possible):
For the genai_api test:
Create and activate a python virtual environment
Run pytest in (myvirtualenv) me@me:~/GenAI-quickstart/genai/api/genai_api/src$ pytest -v
For example on the vertex_chat_api test:
Create and activate a python virtual environment
Run pytest in (myvirtualenv) me@me:~/GenAI-quickstart/genai/api/vertex_chat_api/src$ pytest -v (you'll notice this fails with warning that the 403 Vertex AI API has not been used in project)
Change project_id_response.text to the name of your Google Cloud Project.
Run pytest again in (myvirtualenv) me@me:~/GenAI-quickstart/genai/api/vertex_chat_api/src$ pytest -v. Now the test fails with AssertionError: assert 'test response' == {'mocked_key': 'mocked_value'}.
Anything else we need to know?:
The value test response is coming from the actual call to the LLM. If you run the GenAI Quickstart cluster and navigate to the http://${EXT_IP}/genai_docs (following instructions on the main readme) and enter the same payload prompt as the test "prompt": "test prompt", the response is test response.
The text was updated successfully, but these errors were encountered:
What happened?
When running
pytest -v
in a local virtualenv on thetest_main.py
files:pytest
because the OS environment variables are not in place.pytest
because there is no mock forGoogle_Cloud_GenAI
, so the test tries to connect to a real project and call a LLM in that project.expected_response
since they return a single text stringresponse.text
and not a json object{'mocked_key': 'mocked_value'}
.What you expected to happen:
Running the unit tests should not require setting up environment variables or calls to an external service.
How to reproduce it (as minimally and precisely as possible):
For the genai_api test:
pytest
in(myvirtualenv) me@me:~/GenAI-quickstart/genai/api/genai_api/src$ pytest -v
For example on the vertex_chat_api test:
pytest
in(myvirtualenv) me@me:~/GenAI-quickstart/genai/api/vertex_chat_api/src$ pytest -v
(you'll notice this fails with warning that the403 Vertex AI API has not been used in project
)project_id_response.text
to the name of your Google Cloud Project.GenAI-quickstart/genai/api/vertex_chat_api/src/main.py
Line 45 in 205ba78
pytest
again in(myvirtualenv) me@me:~/GenAI-quickstart/genai/api/vertex_chat_api/src$ pytest -v
. Now the test fails withAssertionError: assert 'test response' == {'mocked_key': 'mocked_value'}
.Anything else we need to know?:
The value
test response
is coming from the actual call to the LLM. If you run the GenAI Quickstart cluster and navigate to the http://${EXT_IP}/genai_docs (following instructions on the main readme) and enter the same payload prompt as the test"prompt": "test prompt"
, the response istest response
.The text was updated successfully, but these errors were encountered: