mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(rpc): add GET /rpc/v5/suggest/{arg} openapi route
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
8e8b746a5b
commit
17f2c05fd3
2 changed files with 28 additions and 0 deletions
|
@ -281,3 +281,15 @@ async def rpc_openapi_search_post(
|
||||||
arg,
|
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()
|
data = resp.json()
|
||||||
expected = "the 'arg' parameter must be of string type"
|
expected = "the 'arg' parameter must be of string type"
|
||||||
assert data.get("error") == expected
|
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue