mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): add /pkgbase/{name}/comments/{id}/undelete (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
40cd1b9029
commit
bb45ae7ac3
2 changed files with 47 additions and 0 deletions
|
@ -1080,6 +1080,7 @@ def test_pkgbase_comments(client: TestClient, maintainer: User, user: User,
|
|||
|
||||
|
||||
def test_pkgbase_comment_delete(client: TestClient,
|
||||
maintainer: User,
|
||||
user: User,
|
||||
package: Package,
|
||||
comment: PackageComment):
|
||||
|
@ -1094,6 +1095,18 @@ def test_pkgbase_comment_delete(client: TestClient,
|
|||
expected = f"/pkgbase/{pkgbasename}"
|
||||
assert resp.headers.get("location") == expected
|
||||
|
||||
# Test the unauthorized case of comment undeletion.
|
||||
maint_cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment.ID}/undelete"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=maint_cookies)
|
||||
assert resp.status_code == int(HTTPStatus.UNAUTHORIZED)
|
||||
|
||||
# And move on to undeleting it.
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
|
||||
def test_pkgbase_comment_delete_unauthorized(client: TestClient,
|
||||
maintainer: User,
|
||||
|
@ -1118,3 +1131,15 @@ def test_pkgbase_comment_delete_not_found(client: TestClient,
|
|||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.NOT_FOUND)
|
||||
|
||||
|
||||
def test_pkgbase_comment_undelete_not_found(client: TestClient,
|
||||
maintainer: User,
|
||||
package: Package):
|
||||
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
|
||||
comment_id = 12345 # Non-existing comment.
|
||||
pkgbasename = package.PackageBase.Name
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment_id}/undelete"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.NOT_FOUND)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue