Skip to content

Commit c40641a

Browse files
committed
update tests
Signed-off-by: Stephanie <[email protected]>
1 parent ff7f062 commit c40641a

File tree

3 files changed

+239
-8
lines changed

3 files changed

+239
-8
lines changed

docs/openapi.json

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,52 @@
123123
}
124124
}
125125
},
126+
"/v1/tools": {
127+
"get": {
128+
"tags": [
129+
"tools"
130+
],
131+
"summary": "Tools Endpoint Handler",
132+
"description": "Handle requests to the /tools endpoint.\n\nProcess GET requests to the /tools endpoint, returning a consolidated list of\navailable tools from all configured MCP servers.\n\nRaises:\n HTTPException: If unable to connect to the Llama Stack server or if\n tool retrieval fails for any reason.\n\nReturns:\n ToolsResponse: An object containing the consolidated list of available tools\n with metadata including tool name, description, parameters, and server source.",
133+
"operationId": "tools_endpoint_handler_v1_tools_get",
134+
"responses": {
135+
"200": {
136+
"description": "Successful Response",
137+
"content": {
138+
"application/json": {
139+
"schema": {
140+
"$ref": "#/components/schemas/ToolsResponse"
141+
},
142+
"example": {
143+
"tools": [
144+
{
145+
"identifier": "",
146+
"description": "",
147+
"parameters": [
148+
{
149+
"name": "",
150+
"description": "",
151+
"parameter_type": "",
152+
"required": "True/False",
153+
"default": "null"
154+
}
155+
],
156+
"provider_id": "",
157+
"toolgroup_id": "",
158+
"server_source": "",
159+
"type": "tool"
160+
}
161+
]
162+
}
163+
}
164+
}
165+
},
166+
"500": {
167+
"description": "Connection to Llama Stack is broken or MCP server error"
168+
}
169+
}
170+
}
171+
},
126172
"/v1/shields": {
127173
"get": {
128174
"tags": [
@@ -945,6 +991,88 @@
945991
}
946992
}
947993
}
994+
},
995+
"put": {
996+
"tags": [
997+
"conversations_v2"
998+
],
999+
"summary": "Update Conversation Endpoint Handler",
1000+
"description": "Handle request to update a conversation topic summary by ID.",
1001+
"operationId": "update_conversation_endpoint_handler_v2_conversations__conversation_id__put",
1002+
"parameters": [
1003+
{
1004+
"name": "conversation_id",
1005+
"in": "path",
1006+
"required": true,
1007+
"schema": {
1008+
"type": "string",
1009+
"title": "Conversation Id"
1010+
}
1011+
}
1012+
],
1013+
"requestBody": {
1014+
"required": true,
1015+
"content": {
1016+
"application/json": {
1017+
"schema": {
1018+
"$ref": "#/components/schemas/ConversationUpdateRequest"
1019+
}
1020+
}
1021+
}
1022+
},
1023+
"responses": {
1024+
"200": {
1025+
"description": "Successful Response",
1026+
"content": {
1027+
"application/json": {
1028+
"schema": {
1029+
"$ref": "#/components/schemas/ConversationUpdateResponse"
1030+
}
1031+
}
1032+
},
1033+
"conversation_id": "123e4567-e89b-12d3-a456-426614174000",
1034+
"success": true,
1035+
"message": "Topic summary updated successfully",
1036+
"topic_summary": "Updated topic summary"
1037+
},
1038+
"400": {
1039+
"description": "Missing or invalid credentials provided by client",
1040+
"content": {
1041+
"application/json": {
1042+
"schema": {
1043+
"$ref": "#/components/schemas/UnauthorizedResponse"
1044+
}
1045+
}
1046+
}
1047+
},
1048+
"401": {
1049+
"description": "Unauthorized: Invalid or missing Bearer token",
1050+
"content": {
1051+
"application/json": {
1052+
"schema": {
1053+
"$ref": "#/components/schemas/UnauthorizedResponse"
1054+
}
1055+
}
1056+
}
1057+
},
1058+
"404": {
1059+
"detail": {
1060+
"response": "Conversation not found",
1061+
"cause": "The specified conversation ID does not exist."
1062+
},
1063+
"description": "Not Found"
1064+
},
1065+
"422": {
1066+
"description": "Validation Error",
1067+
"content": {
1068+
"application/json": {
1069+
"schema": {
1070+
"$ref": "#/components/schemas/HTTPValidationError"
1071+
}
1072+
}
1073+
}
1074+
}
1075+
}
9481076
}
9491077
},
9501078
"/readiness": {
@@ -1114,8 +1242,10 @@
11141242
"get_conversation",
11151243
"list_conversations",
11161244
"delete_conversation",
1245+
"update_conversation",
11171246
"feedback",
11181247
"get_models",
1248+
"get_tools",
11191249
"get_shields",
11201250
"get_metrics",
11211251
"get_config",
@@ -1693,6 +1823,63 @@
16931823
}
16941824
]
16951825
},
1826+
"ConversationUpdateRequest": {
1827+
"properties": {
1828+
"topic_summary": {
1829+
"type": "string",
1830+
"maxLength": 1000,
1831+
"minLength": 1,
1832+
"title": "Topic Summary",
1833+
"description": "The new topic summary for the conversation",
1834+
"examples": [
1835+
"Discussion about machine learning algorithms"
1836+
]
1837+
}
1838+
},
1839+
"additionalProperties": false,
1840+
"type": "object",
1841+
"required": [
1842+
"topic_summary"
1843+
],
1844+
"title": "ConversationUpdateRequest",
1845+
"description": "Model representing a request to update a conversation topic summary.\n\nAttributes:\n topic_summary: The new topic summary for the conversation.\n\nExample:\n ```python\n update_request = ConversationUpdateRequest(\n topic_summary=\"Discussion about machine learning algorithms\"\n )\n ```"
1846+
},
1847+
"ConversationUpdateResponse": {
1848+
"properties": {
1849+
"conversation_id": {
1850+
"type": "string",
1851+
"title": "Conversation Id",
1852+
"description": "The conversation ID (UUID) that was updated",
1853+
"examples": [
1854+
"123e4567-e89b-12d3-a456-426614174000"
1855+
]
1856+
},
1857+
"success": {
1858+
"type": "boolean",
1859+
"title": "Success",
1860+
"description": "Whether the update was successful",
1861+
"examples": [
1862+
true
1863+
]
1864+
},
1865+
"message": {
1866+
"type": "string",
1867+
"title": "Message",
1868+
"description": "A message about the update result",
1869+
"examples": [
1870+
"Topic summary updated successfully"
1871+
]
1872+
}
1873+
},
1874+
"type": "object",
1875+
"required": [
1876+
"conversation_id",
1877+
"success",
1878+
"message"
1879+
],
1880+
"title": "ConversationUpdateResponse",
1881+
"description": "Model representing a response for updating a conversation topic summary.\n\nAttributes:\n conversation_id: The conversation ID (UUID) that was updated.\n success: Whether the update was successful.\n message: A message about the update result.\n\nExample:\n ```python\n update_response = ConversationUpdateResponse(\n conversation_id=\"123e4567-e89b-12d3-a456-426614174000\",\n success=True,\n message=\"Topic summary updated successfully\",\n )\n ```"
1882+
},
16961883
"ConversationsListResponse": {
16971884
"properties": {
16981885
"conversations": {
@@ -3170,6 +3357,45 @@
31703357
"title": "ToolCall",
31713358
"description": "Model representing a tool call made during response generation."
31723359
},
3360+
"ToolsResponse": {
3361+
"properties": {
3362+
"tools": {
3363+
"items": {
3364+
"additionalProperties": true,
3365+
"type": "object"
3366+
},
3367+
"type": "array",
3368+
"title": "Tools",
3369+
"description": "List of tools available from all configured MCP servers and built-in toolgroups",
3370+
"examples": [
3371+
[
3372+
{
3373+
"description": "Read contents of a file from the filesystem",
3374+
"identifier": "filesystem_read",
3375+
"parameters": [
3376+
{
3377+
"description": "Path to the file to read",
3378+
"name": "path",
3379+
"parameter_type": "string",
3380+
"required": true
3381+
}
3382+
],
3383+
"provider_id": "model-context-protocol",
3384+
"server_source": "http://localhost:3000",
3385+
"toolgroup_id": "filesystem-tools",
3386+
"type": "tool"
3387+
}
3388+
]
3389+
]
3390+
}
3391+
},
3392+
"type": "object",
3393+
"required": [
3394+
"tools"
3395+
],
3396+
"title": "ToolsResponse",
3397+
"description": "Model representing a response to tools request."
3398+
},
31733399
"UnauthorizedResponse": {
31743400
"properties": {
31753401
"detail": {

tests/integration/test_openapi_json.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,21 @@ def test_servers_section_present(spec: dict):
7777
"delete",
7878
{"200", "400", "401", "404", "503", "422"},
7979
),
80+
("/v2/conversations", "get", {"200"}),
8081
(
81-
"/v1/conversations/{conversation_id}",
82+
"/v2/conversations/{conversation_id}",
83+
"get",
84+
{"200", "400", "401", "404", "422"},
85+
),
86+
(
87+
"/v2/conversations/{conversation_id}",
88+
"delete",
89+
{"200", "400", "401", "404", "422"},
90+
),
91+
(
92+
"/v2/conversations/{conversation_id}",
8293
"put",
83-
{"200", "400", "401", "404", "503", "422"},
94+
{"200", "400", "401", "404", "422"},
8495
),
8596
("/readiness", "get", {"200", "503"}),
8697
("/liveness", "get", {"200"}),

tests/unit/app/endpoints/test_conversations_v2.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ async def test_configuration_not_loaded(self, mocker, dummy_request):
138138

139139
with pytest.raises(HTTPException) as exc_info:
140140
await update_conversation_endpoint_handler(
141-
request=dummy_request,
142141
conversation_id=VALID_CONVERSATION_ID,
143142
update_request=update_request,
144143
auth=MOCK_AUTH,
@@ -157,7 +156,6 @@ async def test_invalid_conversation_id_format(self, mocker, mock_configuration,
157156

158157
with pytest.raises(HTTPException) as exc_info:
159158
await update_conversation_endpoint_handler(
160-
request=dummy_request,
161159
conversation_id=INVALID_CONVERSATION_ID,
162160
update_request=update_request,
163161
auth=MOCK_AUTH,
@@ -179,7 +177,6 @@ async def test_conversation_cache_not_configured(self, mocker, dummy_request):
179177

180178
with pytest.raises(HTTPException) as exc_info:
181179
await update_conversation_endpoint_handler(
182-
request=dummy_request,
183180
conversation_id=VALID_CONVERSATION_ID,
184181
update_request=update_request,
185182
auth=MOCK_AUTH,
@@ -200,7 +197,6 @@ async def test_conversation_not_found(self, mocker, mock_configuration, dummy_re
200197

201198
with pytest.raises(HTTPException) as exc_info:
202199
await update_conversation_endpoint_handler(
203-
request=dummy_request,
204200
conversation_id=VALID_CONVERSATION_ID,
205201
update_request=update_request,
206202
auth=MOCK_AUTH,
@@ -222,7 +218,6 @@ async def test_successful_update(self, mocker, mock_configuration, dummy_request
222218
update_request = ConversationUpdateRequest(topic_summary="New topic summary")
223219

224220
response = await update_conversation_endpoint_handler(
225-
request=dummy_request,
226221
conversation_id=VALID_CONVERSATION_ID,
227222
update_request=update_request,
228223
auth=MOCK_AUTH,
@@ -232,7 +227,6 @@ async def test_successful_update(self, mocker, mock_configuration, dummy_request
232227
assert response.conversation_id == VALID_CONVERSATION_ID
233228
assert response.success is True
234229
assert response.message == "Topic summary updated successfully"
235-
assert response.topic_summary == "New topic summary"
236230

237231
# Verify that set_topic_summary was called
238232
mock_configuration.conversation_cache.set_topic_summary.assert_called_once_with(

0 commit comments

Comments
 (0)