Verified Commit 8e8b746a authored by Kevin Morris's avatar Kevin Morris
Browse files

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



Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 5e75a00c
......@@ -217,12 +217,29 @@ async def rpc_openapi_multiinfo_post(
)
@router.get("/rpc/v{version}/search/{arg}")
async def rpc_openapi_search_arg(
request: Request,
version: int,
arg: str,
by: Optional[str] = Query(default=defaults.RPC_SEARCH_BY),
):
return await rpc_request(
request,
version,
"search",
by,
arg,
[],
)
@router.get("/rpc/v{version}/search")
async def rpc_openapi_search(
request: Request,
version: int,
by: Optional[str] = Query(default=defaults.RPC_SEARCH_BY),
arg: Optional[str] = Query(default=str()),
by: Optional[str] = Query(default=defaults.RPC_SEARCH_BY),
):
return await rpc_request(
request,
......
......@@ -986,6 +986,18 @@ def test_rpc_openapi_multiinfo_post_bad_request(
assert data.get("error") == expected
def test_rpc_openapi_search_arg(client: TestClient, packages: list[Package]):
pkgname = packages[0].Name
with client as request:
endp = f"/rpc/v5/search/{pkgname}"
resp = request.get(endp)
assert resp.status_code == HTTPStatus.OK
data = resp.json()
assert data.get("resultcount") == 1
def test_rpc_openapi_search(client: TestClient, packages: list[Package]):
pkgname = packages[0].Name
......
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