mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): add /pkgbase/{name}/[un]vote (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
0dfff2bcb2
commit
0a02df363a
2 changed files with 65 additions and 0 deletions
|
@ -1753,3 +1753,30 @@ def test_pkgbase_notify(client: TestClient, user: User, package: Package):
|
|||
PackageNotification.UserID == user.ID
|
||||
).first()
|
||||
assert notif is None
|
||||
|
||||
|
||||
def test_pkgbase_vote(client: TestClient, user: User, package: Package):
|
||||
pkgbase = package.PackageBase
|
||||
|
||||
# We haven't voted yet.
|
||||
vote = pkgbase.package_votes.filter(PackageVote.UsersID == user.ID).first()
|
||||
assert vote is None
|
||||
|
||||
# Vote for the package.
|
||||
cookies = {"AURSID": user.login(Request(), "testPassword")}
|
||||
endpoint = f"/pkgbase/{pkgbase.Name}/vote"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
vote = pkgbase.package_votes.filter(PackageVote.UsersID == user.ID).first()
|
||||
assert vote is not None
|
||||
|
||||
# Remove vote.
|
||||
endpoint = f"/pkgbase/{pkgbase.Name}/unvote"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
vote = pkgbase.package_votes.filter(PackageVote.UsersID == user.ID).first()
|
||||
assert vote is None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue