feat(FastAPI): add /pkgbase/{name}/flag-comment (get)

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-15 18:38:10 -07:00
parent 210d92e382
commit 37f0c352f6
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
4 changed files with 81 additions and 5 deletions

View file

@ -1707,6 +1707,14 @@ def test_pkgbase_flag(client: TestClient, user: User, maintainer: User,
resp = request.get(endpoint, cookies=cookies)
assert resp.status_code == int(HTTPStatus.OK)
# Now, let's check the /pkgbase/{name}/flag-comment route.
flag_comment_endpoint = f"/pkgbase/{pkgbase.Name}/flag-comment"
with client as request:
resp = request.get(flag_comment_endpoint, cookies=cookies,
allow_redirects=False)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == f"/pkgbase/{pkgbase.Name}"
# Try to flag it without a comment.
with client as request:
resp = request.post(endpoint, cookies=cookies)
@ -1721,6 +1729,13 @@ def test_pkgbase_flag(client: TestClient, user: User, maintainer: User,
assert pkgbase.Flagger == user
assert pkgbase.FlaggerComment == "Test"
# Now, let's check the /pkgbase/{name}/flag-comment route.
flag_comment_endpoint = f"/pkgbase/{pkgbase.Name}/flag-comment"
with client as request:
resp = request.get(flag_comment_endpoint, cookies=cookies,
allow_redirects=False)
assert resp.status_code == int(HTTPStatus.OK)
# Now try to perform a get; we should be redirected because
# it's already flagged.
with client as request: