mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(rpc): restore "Too Many Package Results" error
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
86caee74c5
commit
3af66cafbe
2 changed files with 41 additions and 2 deletions
|
@ -795,3 +795,34 @@ def test_rpc_post(client: TestClient, packages: List[Package]):
|
|||
resp = request.post("/rpc", data=data)
|
||||
assert resp.status_code == int(HTTPStatus.OK)
|
||||
assert resp.json().get("resultcount") == 2
|
||||
|
||||
|
||||
def test_rpc_too_many_search_results(client: TestClient,
|
||||
packages: List[Package]):
|
||||
config_getint = config.getint
|
||||
|
||||
def mock_config(section: str, key: str):
|
||||
if key == "max_rpc_results":
|
||||
return 1
|
||||
return config_getint(section, key)
|
||||
|
||||
params = {"v": 5, "type": "search", "arg": "chungus"}
|
||||
with mock.patch("aurweb.config.getint", side_effect=mock_config):
|
||||
with client as request:
|
||||
resp = request.get("/rpc", params=params)
|
||||
assert resp.json().get("error") == "Too many package results."
|
||||
|
||||
|
||||
def test_rpc_too_many_info_results(client: TestClient, packages: List[Package]):
|
||||
config_getint = config.getint
|
||||
|
||||
def mock_config(section: str, key: str):
|
||||
if key == "max_rpc_results":
|
||||
return 1
|
||||
return config_getint(section, key)
|
||||
|
||||
params = {"v": 5, "type": "info", "arg[]": [p.Name for p in packages]}
|
||||
with mock.patch("aurweb.config.getint", side_effect=mock_config):
|
||||
with client as request:
|
||||
resp = request.get("/rpc", params=params)
|
||||
assert resp.json().get("error") == "Too many package results."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue