ticket #65 attempt 1
This commit is contained in:
@@ -345,3 +345,22 @@ def test_comment_links_multiple_attachments(app_server):
|
||||
assert u1 in r.text and u2 in r.text, (
|
||||
"both attachments must be linked and displayed on the comment"
|
||||
)
|
||||
|
||||
|
||||
def test_create_comment_too_long_rejected(app_server):
|
||||
from devplacepy.config import COMMENT_MAX_LENGTH
|
||||
s, _ = _session_comments()
|
||||
post_uid = _create_post_comments(s, f"cmt-long-{int(time.time() * 1000)}")
|
||||
r = s.post(
|
||||
f"{BASE_URL}/comments/create",
|
||||
data={
|
||||
"content": "x" * (COMMENT_MAX_LENGTH + 1),
|
||||
"target_type": "post",
|
||||
"post_uid": post_uid,
|
||||
"target_uid": post_uid,
|
||||
},
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert r.status_code in (400, 422), r.text[:300]
|
||||
refresh_snapshot()
|
||||
assert get_table("comments").find_one(target_uid=post_uid) is None
|
||||
|
||||
@@ -129,3 +129,19 @@ def test_edit_comment_too_short_rejected(app_server):
|
||||
assert r.status_code in (400, 422)
|
||||
refresh_snapshot()
|
||||
assert get_table("comments").find_one(uid=comment["uid"])["content"] == "Long enough body"
|
||||
|
||||
|
||||
def test_edit_comment_too_long_rejected(app_server):
|
||||
from devplacepy.config import COMMENT_MAX_LENGTH
|
||||
s, _ = _session_edit()
|
||||
post_uid = _create_post_edit(s, f"edit-long-{int(time.time() * 1000)}")
|
||||
comment = _create_comment_edit(s, post_uid, "Normal body length")
|
||||
r = s.post(
|
||||
f"{BASE_URL}/comments/edit/{comment['uid']}",
|
||||
headers=JSON_edit,
|
||||
data={"content": "x" * (COMMENT_MAX_LENGTH + 1)},
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert r.status_code in (400, 422), r.text[:300]
|
||||
refresh_snapshot()
|
||||
assert get_table("comments").find_one(uid=comment["uid"])["content"] == "Normal body length"
|
||||
|
||||
Reference in New Issue
Block a user