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}/unpin (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
0895dd07ee
commit
2efd254974
2 changed files with 48 additions and 0 deletions
|
@ -1152,11 +1152,25 @@ def test_pkgbase_comment_pin(client: TestClient,
|
|||
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
|
||||
comment_id = comment.ID
|
||||
pkgbasename = package.PackageBase.Name
|
||||
|
||||
# Pin the comment.
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment_id}/pin"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
# Assert that PinnedTS got set.
|
||||
assert comment.PinnedTS > 0
|
||||
|
||||
# Unpin the comment we just pinned.
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment_id}/unpin"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
# Let's assert that PinnedTS was unset.
|
||||
assert comment.PinnedTS == 0
|
||||
|
||||
|
||||
def test_pkgbase_comment_pin_unauthorized(client: TestClient,
|
||||
user: User,
|
||||
|
@ -1169,3 +1183,16 @@ def test_pkgbase_comment_pin_unauthorized(client: TestClient,
|
|||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.UNAUTHORIZED)
|
||||
|
||||
|
||||
def test_pkgbase_comment_unpin_unauthorized(client: TestClient,
|
||||
user: User,
|
||||
package: Package,
|
||||
comment: PackageComment):
|
||||
cookies = {"AURSID": user.login(Request(), "testPassword")}
|
||||
comment_id = comment.ID
|
||||
pkgbasename = package.PackageBase.Name
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment_id}/unpin"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.UNAUTHORIZED)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue