Verified Commit 17f2c05f authored by Kevin Morris's avatar Kevin Morris
Browse files

feat(rpc): add GET /rpc/v5/suggest/{arg} openapi route



Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 8e8b746a
......@@ -281,3 +281,15 @@ async def rpc_openapi_search_post(
arg,
[],
)
@router.get("/rpc/v{version}/suggest/{arg}")
async def rpc_openapi_suggest(request: Request, version: int, arg: str):
return await rpc_request(
request,
version,
"suggest",
defaults.RPC_SEARCH_BY,
arg,
[],
)
......@@ -1040,3 +1040,19 @@ def test_rpc_openapi_search_post_bad_request(client: TestClient):
data = resp.json()
expected = "the 'arg' parameter must be of string type"
assert data.get("error") == expected
def test_rpc_openapi_suggest(client: TestClient, packages: list[Package]):
suggestions = {
"big": ["big-chungus"],
"chungy": ["chungy-chungus"],
}
for term, expected in suggestions.items():
with client as request:
endp = f"/rpc/v5/suggest/{term}"
resp = request.get(endp)
assert resp.status_code == HTTPStatus.OK
data = resp.json()
assert data == expected
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment