fix(rpc): display rpc doc when no query string is provided

Closes #255

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-01-13 21:32:13 -08:00
parent 60ae676075
commit 43b7fdb61d
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 43 additions and 2 deletions

View file

@ -14,7 +14,7 @@ from redis.client import Pipeline
import aurweb.models.dependency_type as dt
import aurweb.models.relation_type as rt
from aurweb import asgi, config, db, scripts
from aurweb import asgi, config, db, rpc, scripts
from aurweb.models.account_type import USER_ID
from aurweb.models.license import License
from aurweb.models.package import Package
@ -215,6 +215,29 @@ def pipeline():
yield pipeline
def test_rpc_documentation(client: TestClient):
with client as request:
resp = request.get("/rpc")
assert resp.status_code == int(HTTPStatus.OK)
assert "aurweb RPC Interface" in resp.text
def test_rpc_documentation_missing():
config_get = config.get
def mock_get(section: str, key: str) -> str:
if section == "options" and key == "aurwebdir":
return "/missing"
return config_get(section, key)
with mock.patch("aurweb.config.get", side_effect=mock_get):
config.rehash()
expr = r"^doc/rpc\.html could not be read$"
with pytest.raises(OSError, match=expr):
rpc.documentation()
config.rehash()
def test_rpc_singular_info(client: TestClient,
user: User,
packages: List[Package],