Merge branch 'react-native' into release/1026-merge
# Conflicts: # backend/common/enums.py # backend/router/v1/auth/account.py # frontend/.dockerignore # frontend/package-lock.json # frontend/package.json # frontend/public/terms.html # frontend/src/api/client/index.ts # frontend/src/b/BLayout.tsx # frontend/src/b/Sheets.tsx # shared/api/client/@tanstack/react-query.gen.ts # shared/api/client/sdk.gen.ts # shared/api/client/types.gen.ts
This commit is contained in:
commit
5d18fa51fa
148 files changed
+21940
-4532
No files matched your search
@@ -43,7 +43,7 @@ def anyio_backend():
|
||||
|
||||
_VOLATILE = (
|
||||
"weather_hourly", "weather_daily", "cloud_hourly", "openmeteo_hourly", "air_station", "air_quality", "weather_warning", "sun_time",
|
||||
"sky_score", "index_score", "post", "post_like", "post_like_anon", "post_save", "comment", "comment_like", "comment_like_anon", "holiday", "solar_term", "users", "card_set", "card_image", "reel",
|
||||
"sky_score", "index_score", "post", "post_like", "post_like_anon", "post_save", "comment", "comment_like", "comment_like_anon", "comment_report", "user_block", "holiday", "solar_term", "users", "card_set", "card_image", "reel",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ def client():
|
||||
|
||||
async def _login(c, login_id: str) -> dict:
|
||||
body = (await c.post("/v1/auth/signup", json={"login_id": login_id, "password": "password1", "nickname": login_id})).json()
|
||||
return {"Authorization": f"Bearer {body['access_token']}"}
|
||||
h = {"Authorization": f"Bearer {body['access_token']}"}
|
||||
await c.post("/v1/auth/terms", headers=h) # 로그인한 사람은 약관에 동의해야 댓글을 쓴다
|
||||
return h
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -147,3 +149,26 @@ async def test_hero_tomorrow_and_tomorrow_slots(offline):
|
||||
assert set(hero["tomorrow"]["weather_slots"]) <= {"morning", "day", "evening", "night"}
|
||||
res = (await c.get("/v1/weather/today", params={"region": REGION, "day": "tomorrow"})).json()
|
||||
assert res["day"] == hero["tomorrow"]["day"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_anon_comment_can_be_reported_not_blocked(offline):
|
||||
"""로그인 없이 쓴 댓글도 신고는 되고(신고한 사람에겐 숨김), 차단할 사람이 없어 차단은 안 된다. 다른 사람을 차단해도 익명 댓글은 그대로 보인다."""
|
||||
async with client() as c:
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
url = f"/v1/reaction/post/{post_id}/comment"
|
||||
listing = f"{url}/list"
|
||||
anon_id = (await c.post(url, headers=IP_A, json={"body": "익명 댓글"})).json()["comment"]["comment_id"]
|
||||
writer = await _login(c, "anon_mod_01")
|
||||
writer_id = (await c.post(url, headers=writer, json={"body": "회원 댓글"})).json()["comment"]["comment_id"]
|
||||
viewer = await _login(c, "anon_mod_02")
|
||||
|
||||
blocked = (await c.post(f"/v1/reaction/comment/{writer_id}/block", headers=viewer)).json()
|
||||
assert blocked["result"]["success"] is True
|
||||
ids = [x["comment_id"] for x in (await c.get(listing, headers=viewer)).json()["comments"]]
|
||||
assert anon_id in ids and writer_id not in ids
|
||||
|
||||
assert (await c.post(f"/v1/reaction/comment/{anon_id}/block", headers=viewer)).json()["result"]["desc"] == "INVALID_INPUT"
|
||||
assert (await c.post(f"/v1/reaction/comment/{anon_id}/report", headers=viewer, json={"reason": 1})).json()["result"]["success"] is True
|
||||
assert anon_id not in [x["comment_id"] for x in (await c.get(listing, headers=viewer)).json()["comments"]]
|
||||
assert anon_id in [x["comment_id"] for x in (await c.get(listing, headers=IP_B)).json()["comments"]]
|
||||
@@ -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
|
||||
@@ -122,3 +126,118 @@ async def test_logout_invalidates_access_and_refresh_tokens():
|
||||
assert (await c.post("/v1/auth/refresh", json={"refresh_token": body["refresh_token"]})).json()["result"]["desc"] == "AUTH_TOKEN_INVALID"
|
||||
again = (await c.post("/v1/auth/login", json={"login_id": "mina_out", "password": "password1"})).json()
|
||||
assert (await c.get("/v1/auth/me", headers={"Authorization": f"Bearer {again['access_token']}"})).status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_withdraw_deletes_account_and_reactions(offline):
|
||||
async with client() as c:
|
||||
body = await _signup(c, login_id="mina_bye")
|
||||
h = {"Authorization": f"Bearer {body['access_token']}"}
|
||||
other = {"Authorization": f"Bearer {(await _signup(c, 'other_bye', '남는사람'))['access_token']}"}
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
await c.post(f"/v1/reaction/post/{post_id}/like", headers=h)
|
||||
await c.post(f"/v1/reaction/post/{post_id}/save", headers=h)
|
||||
mine = (await c.post(f"/v1/reaction/post/{post_id}/comment", headers=h, json={"body": "곧 떠나요"})).json()["comment"]
|
||||
kept = (await c.post(f"/v1/reaction/post/{post_id}/comment", headers=other, json={"body": "남아요"})).json()["comment"]
|
||||
await c.post(f"/v1/reaction/comment/{kept['comment_id']}/like", headers=h)
|
||||
await c.post(f"/v1/reaction/comment/{mine['comment_id']}/like", headers=other)
|
||||
|
||||
assert (await c.delete("/v1/auth/me")).status_code == 401
|
||||
assert (await c.delete("/v1/auth/me", headers=h)).json()["result"]["success"] is True
|
||||
|
||||
assert (await c.get("/v1/auth/me", headers=h)).status_code == 401
|
||||
assert (await c.post("/v1/auth/refresh", json={"refresh_token": body["refresh_token"]})).json()["result"]["desc"] == "AUTH_TOKEN_INVALID"
|
||||
assert (await c.post("/v1/auth/login", json={"login_id": "mina_bye", "password": "password1"})).json()["result"]["desc"] == "AUTH_FAILED"
|
||||
comments = (await c.get(f"/v1/reaction/post/{post_id}/comment/list")).json()["comments"]
|
||||
assert [x["body"] for x in comments] == ["남아요"] and comments[0]["like_count"] == 0
|
||||
p = next(x for x in (await c.get("/v1/feed", params={"region": REGION})).json()["posts"] if x["post_id"] == post_id)
|
||||
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) == ["남아요"]
|
||||
@@ -84,6 +84,7 @@ async def test_like_in_one_sido_not_seen_in_another(offline):
|
||||
async with client() as c:
|
||||
token = (await c.post("/v1/auth/signup", json={"login_id": "scope_01", "password": "password1", "nickname": "시도테스트"})).json()["access_token"]
|
||||
h = {"Authorization": f"Bearer {token}"}
|
||||
await c.post("/v1/auth/terms", headers=h)
|
||||
seoul = (await c.get("/v1/feed", params={"region": SEOUL_A}, headers=h)).json()
|
||||
post_id = next(p["post_id"] for p in seoul["posts"] if p["post_type"] == PostType.WEATHER.value)
|
||||
assert (await c.post(f"/v1/reaction/post/{post_id}/like", headers=h)).json()["like_count"] == 1
|
||||
|
||||
Reference in new issue
Block a user