feat(FastAPI): add /pkgbase/{name}/comments/{id}/unpin (post)

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-01 17:51:39 -07:00
parent 0895dd07ee
commit 2efd254974
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
2 changed files with 48 additions and 0 deletions

View file

@ -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)