feat: 댓글 신고·차단·약관 동의(관리 스크립트 포함), 구글 로그인(서버·웹·안드로이드 앱), 앱 패키지 kr.o2o.nalssigak·versionCode 1000
This commit is contained in:
1 parent
fbebdcb796
commit
3f3a3ea039
35 files changed
+1723
-115
No files matched your search
@@ -10,8 +10,12 @@ def client():
|
||||
return AsyncClient(transport=ASGITransport(app=app), base_url="http://test")
|
||||
|
||||
|
||||
async def _signup(c, login_id="mina_01", nickname="망원동주민"):
|
||||
return (await c.post("/v1/auth/signup", json={"login_id": login_id, "password": "password1", "nickname": nickname})).json()
|
||||
async def _signup(c, login_id="mina_01", nickname="망원동주민", agree=True):
|
||||
"""가입하고, 댓글을 쓸 수 있게 이용약관에도 동의한다 (agree=False 면 안 함)."""
|
||||
body = (await c.post("/v1/auth/signup", json={"login_id": login_id, "password": "password1", "nickname": nickname})).json()
|
||||
if agree and body.get("access_token"):
|
||||
await c.post("/v1/auth/terms", headers={"Authorization": f"Bearer {body['access_token']}"})
|
||||
return body
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -149,3 +153,90 @@ async def test_withdraw_deletes_account_and_reactions(offline):
|
||||
assert p["like_count"] == 0 and p["comment_count"] == 1
|
||||
# 같은 아이디로 다시 가입할 수 있다
|
||||
assert (await _signup(c, login_id="mina_bye"))["result"]["success"] is True
|
||||
|
||||
|
||||
def _h(body):
|
||||
return {"Authorization": f"Bearer {body['access_token']}"}
|
||||
|
||||
|
||||
async def _comment(c, post_id, h, text):
|
||||
return (await c.post(f"/v1/reaction/post/{post_id}/comment", headers=h, json={"body": text})).json()
|
||||
|
||||
|
||||
async def _bodies(c, post_id, h=None):
|
||||
return [x["body"] for x in (await c.get(f"/v1/reaction/post/{post_id}/comment/list", headers=h or {})).json()["comments"]]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_comment_needs_terms_agreement(offline):
|
||||
async with client() as c:
|
||||
h = _h(await _signup(c, agree=False))
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
assert (await c.get("/v1/auth/me", headers=h)).json()["me"]["terms_agreed"] is False
|
||||
assert (await _comment(c, post_id, h, "안녕"))["result"]["desc"] == "TERMS_REQUIRED"
|
||||
assert (await c.post("/v1/auth/terms", headers=h)).json()["me"]["terms_agreed"] is True
|
||||
assert (await _comment(c, post_id, h, "안녕"))["comment"]["body"] == "안녕"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_report_hides_for_reporter_then_for_all_at_three(offline):
|
||||
async with client() as c:
|
||||
writer = _h(await _signup(c, "writer_1", "쓴사람"))
|
||||
r = [_h(await _signup(c, f"reporter_{i}", f"신고자{i}")) for i in range(3)]
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
bad = (await _comment(c, post_id, writer, "광고입니다"))["comment"]
|
||||
url = f"/v1/reaction/comment/{bad['comment_id']}/report"
|
||||
|
||||
assert (await c.post(url, headers=writer, json={"reason": 2})).json()["result"]["desc"] == "INVALID_INPUT"
|
||||
assert (await c.post(url, headers=r[0], json={"reason": 9})).status_code == 422
|
||||
assert (await c.post(url, headers=r[0], json={"reason": 2})).json()["result"]["success"] is True
|
||||
assert (await c.post(url, headers=r[0], json={"reason": 2})).json()["result"]["success"] is True # 두 번 신고해도 한 번
|
||||
assert await _bodies(c, post_id, r[0]) == [] and await _bodies(c, post_id, r[1]) == ["광고입니다"]
|
||||
|
||||
await c.post(url, headers=r[1], json={"reason": 1})
|
||||
assert await _bodies(c, post_id) == ["광고입니다"]
|
||||
await c.post(url, headers=r[2], json={"reason": 1})
|
||||
assert await _bodies(c, post_id) == [] and await _bodies(c, post_id, writer) == []
|
||||
p = next(x for x in (await c.get("/v1/feed", params={"region": REGION})).json()["posts"] if x["post_id"] == post_id)
|
||||
assert p["comment_count"] == 0
|
||||
# 숨긴 댓글을 지워도 댓글 수가 한 번 더 줄지 않는다
|
||||
assert (await c.delete(f"/v1/reaction/comment/{bad['comment_id']}", headers=writer)).json()["result"]["success"] is True
|
||||
p = next(x for x in (await c.get("/v1/feed", params={"region": REGION})).json()["posts"] if x["post_id"] == post_id)
|
||||
assert p["comment_count"] == 0
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_block_hides_author_comments_and_can_be_undone(offline):
|
||||
async with client() as c:
|
||||
me = _h(await _signup(c))
|
||||
other = _h(await _signup(c, "rude_1", "무례한"))
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
rude = (await _comment(c, post_id, other, "흥"))["comment"]
|
||||
mine = (await _comment(c, post_id, me, "좋아요"))["comment"]
|
||||
|
||||
assert (await c.post(f"/v1/reaction/comment/{mine['comment_id']}/block", headers=me)).json()["result"]["desc"] == "INVALID_INPUT"
|
||||
assert (await c.post(f"/v1/reaction/comment/{rude['comment_id']}/block")).status_code == 401
|
||||
assert (await c.post(f"/v1/reaction/comment/{rude['comment_id']}/block", headers=me)).json()["result"]["success"] is True
|
||||
assert await _bodies(c, post_id, me) == ["좋아요"] and await _bodies(c, post_id) == ["흥", "좋아요"]
|
||||
|
||||
blocked = (await c.get("/v1/reaction/block/list", headers=me)).json()["users"]
|
||||
assert [u["nickname"] for u in blocked] == ["무례한"]
|
||||
assert (await c.delete(f"/v1/reaction/block/{blocked[0]['user_id']}", headers=me)).json()["result"]["success"] is True
|
||||
assert (await c.delete(f"/v1/reaction/block/{blocked[0]['user_id']}", headers=me)).json()["result"]["desc"] == "NOT_FOUND"
|
||||
assert await _bodies(c, post_id, me) == ["흥", "좋아요"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_withdraw_removes_reports_and_blocks(offline):
|
||||
async with client() as c:
|
||||
leaver = _h(await _signup(c, "leaver_1", "떠날사람"))
|
||||
stay = _h(await _signup(c, "stay_1", "남는사람"))
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
kept = (await _comment(c, post_id, stay, "남아요"))["comment"]
|
||||
gone = (await _comment(c, post_id, leaver, "떠나요"))["comment"]
|
||||
await c.post(f"/v1/reaction/comment/{kept['comment_id']}/report", headers=leaver, json={"reason": 4})
|
||||
await c.post(f"/v1/reaction/comment/{kept['comment_id']}/block", headers=leaver)
|
||||
await c.post(f"/v1/reaction/comment/{gone['comment_id']}/block", headers=stay)
|
||||
assert (await c.delete("/v1/auth/me", headers=leaver)).json()["result"]["success"] is True
|
||||
assert (await c.get("/v1/reaction/block/list", headers=stay)).json()["users"] == []
|
||||
assert await _bodies(c, post_id, stay) == ["남아요"]
|
||||
Reference in new issue
Block a user