mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): add /pkgbase/{name}/[un]notify (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
8eadb4251d
commit
0dfff2bcb2
2 changed files with 69 additions and 0 deletions
|
@ -1720,3 +1720,36 @@ def test_pkgbase_flag(client: TestClient, user: User, maintainer: User,
|
|||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
assert pkgbase.Flagger is None
|
||||
|
||||
|
||||
def test_pkgbase_notify(client: TestClient, user: User, package: Package):
|
||||
pkgbase = package.PackageBase
|
||||
|
||||
# We have no notif record yet; assert that.
|
||||
notif = pkgbase.notifications.filter(
|
||||
PackageNotification.UserID == user.ID
|
||||
).first()
|
||||
assert notif is None
|
||||
|
||||
# Enable notifications.
|
||||
cookies = {"AURSID": user.login(Request(), "testPassword")}
|
||||
endpoint = f"/pkgbase/{pkgbase.Name}/notify"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
notif = pkgbase.notifications.filter(
|
||||
PackageNotification.UserID == user.ID
|
||||
).first()
|
||||
assert notif is not None
|
||||
|
||||
# Disable notifications.
|
||||
endpoint = f"/pkgbase/{pkgbase.Name}/unnotify"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
notif = pkgbase.notifications.filter(
|
||||
PackageNotification.UserID == user.ID
|
||||
).first()
|
||||
assert notif is None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue