Skip to content

Commit

Permalink
refactor (backend/tests): resolve failing backend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed Nov 6, 2024
1 parent 7f1342c commit 2c1b5c4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 44 deletions.
4 changes: 2 additions & 2 deletions agenta-backend/agenta_backend/routers/variants_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ async def configs_commit(
):
config = await commit_config( # type: ignore
project_id=request.state.project_id,
config=config, # type: ignore
config=config.config, # type: ignore
user_id=request.state.user_id,
)

Expand Down Expand Up @@ -764,7 +764,7 @@ async def configs_list(
):
configs = await list_configs(
project_id=request.state.project_id,
application_ref=application_ref, # type: ignore
application_ref=application_ref.application_ref, # type: ignore
user_id=request.state.user_id,
)

Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/services/variants_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ async def _fetch_variant_versions(
logger.warning("[HELPERS]: Fetching variant versions")

with suppress():
app_variant = None
if variant_ref.id:
app_variant = await db_manager.fetch_app_variant_by_id(
app_variant_id=variant_ref.id.hex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,37 @@ async def test_configs_commit_success(
response = await test_client.post(
"/api/variants/configs/commit",
json={
"params": {
"model": "gpt-4",
"top_p": 1,
"inputs": [{"name": "country"}],
"force_json": 0,
"max_tokens": 1000,
"prompt_user": "What is the capital of {country}?",
"temperature": 0.65,
"prompt_system": "You are an expert in geography.",
"presence_penalty": 0,
"frequence_penalty": 0,
},
"url": "http://localhost/0192a45c-4630-7130-8d59-7036ec84002f/test/app",
"application_ref": {
"slug": None,
"version": None,
"id": str(app.id),
},
"service_ref": {
"slug": "app",
"version": None,
"id": "0192a45c-4630-7130-8d59-7036ec84002f",
},
"variant_ref": {
"slug": variant_revision.config_name,
"version": variant_revision.revision,
"id": str(variant_revision.id),
},
"environment_ref": None,
"config": {
"params": {
"model": "gpt-4",
"top_p": 1,
"inputs": [{"name": "country"}],
"force_json": 0,
"max_tokens": 1000,
"prompt_user": "What is the capital of {country}?",
"temperature": 0.65,
"prompt_system": "You are an expert in geography.",
"presence_penalty": 0,
"frequence_penalty": 0,
},
"url": "http://localhost/0192a45c-4630-7130-8d59-7036ec84002f/test/app",
"application_ref": {
"slug": None,
"version": None,
"id": str(app.id),
},
"service_ref": {
"slug": "app",
"version": None,
"id": "0192a45c-4630-7130-8d59-7036ec84002f",
},
"variant_ref": {
"slug": variant_revision.config_name,
"version": variant_revision.revision,
"id": str(variant_revision.id),
},
"environment_ref": None,
}
},
)
assert response.status_code == status.HTTP_200_OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ async def test_configs_delete_not_found(get_app_by_name):
},
)
assert response.status_code == status.HTTP_200_OK
assert None == response.json()
assert 204 == response.json()
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ async def test_configs_history_not_found(get_app_by_name):
app_not_found_response = await test_client.post(
"/api/variants/configs/history",
json={
"slug": "non_existent_app",
"version": None,
"id": None,
"variant_ref": {
"slug": "non_existent_app",
"version": None,
"id": None,
}
},
)
variant_not_found_response = await test_client.post(
"/api/variants/configs/history",
json={
"slug": None,
"version": None,
"id": "f7c93215-b728-4b24-ae8d-2a611c68cdb2",
"variant_ref": {
"slug": None,
"version": None,
"id": "f7c93215-b728-4b24-ae8d-2a611c68cdb2",
}
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ async def test_configs_list_success(get_app_by_name):
response = await test_client.post(
"/api/variants/configs/list",
json={
"slug": app.app_name,
"version": None,
"id": None,
"application_ref": {
"slug": app.app_name,
"version": None,
"id": None,
}
},
)

Expand All @@ -44,9 +46,11 @@ async def test_configs_list_not_found(get_app_by_name):
response = await test_client.post(
"/api/variants/configs/list",
json={
"slug": "non_existent_app",
"version": None,
"id": None,
"application_ref": {
"slug": "non_existent_app",
"version": None,
"id": None,
}
},
)

Expand Down

0 comments on commit 2c1b5c4

Please sign in to comment.