[WIP] Backend: mock integration tests #906
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mocking Model Deployments in integrations tests
AI Description
This PR introduces several changes to the backend integration and unit tests, as well as updates to various files in the src/backend directory.
Backend Integration and Unit Tests
backend_integration_tests.yml
andbackend_unit_tests.yml
files have been updated to include additional steps for setting up the Python environment, installing dependencies, and configuring the test database.pytest_integration.ini
file has been modified to include a new filter for warnings related to thepydantic
module.src/backend Directory
model_deployments
module has been updated to:list_models
method in theazure.py
,bedrock.py
,cohere_platform.py
,sagemaker.py
, andsingle_container.py
files.list_models
andis_available
methods in thebase.py
file.invoke_rerank
method in theazure.py
,bedrock.py
,cohere_platform.py
,sagemaker.py
, andsingle_container.py
files.routers/organization.py
file has been modified to use themodel_dump()
method instead ofdict()
when creating an organization.schemas/context.py
file has been updated to:with_user
,with_agent
,with_model
,with_deployment_config
,with_conversation_id
,with_stream_start_ms
,with_agent_id
,with_organization_id
,with_organization
,with_global_filtering
, andwithout_global_filtering
.Self
type to the parameter of thewith_user
method.services/conversation.py
file has been modified to:get_documents_to_rerank
method.filter_conversations
method.tests/integration/conftest.py
file has been updated to include a return type for theclient
function.tests/integration/crud/test_deployment.py
file has been modified to:session
anddeployment
parameters in several test functions.Session
class fromsqlalchemy.orm
.tests/integration/crud/test_model.py
file has been updated to:session
anddeployment
parameters in several test functions.Session
class fromsqlalchemy.orm
.tests/integration/routers/test_agent.py
file has been modified to:user
parameter in several test functions.User
class frombackend.schemas.user
.tests/integration/routers/test_conversation.py
file has been updated to:os
import._IS_GOOGLE_CLOUD_API_KEY_SET
to store the result ofSettings().get('google_cloud.api_key')
.mock_available_model_deployments
parameter.tests/integration/routers/test_model.py
file has been updated to:deployment
parameter in several test functions.Session
class fromsqlalchemy.orm
.tests/unit/model_deployments/mock_deployments/mock_azure.py
,mock_bedrock.py
,mock_sagemaker.py
, andmock_single_container.py
files have been modified to change the method decorator of theis_available
method.tests/unit/model_deployments/mock_deployments/mock_cohere_platform.py
file has been updated to:random
import.is_available
method.invoke_chat
andinvoke_rerank
methods to be asynchronous and include additional logic.tests/unit/routers/test_organization.py
file has been modified to use themodel_dump()
method instead ofdict()
when creating an organization.