feat: 10/21 회의 반영 — 공유 링크·로그인 없이 댓글·구글 로그인만, 히어로·오늘의 각 좋아요·댓글, 히어로 오늘/내일 스위치, 단풍 지도 65곳·3단계
- 공유: 이미지와 함께 고정 URL을 넘기고 링크도 클립보드에 복사 - 로그인 창은 구글만, 댓글은 로그인 없이 '동네 익명'(링크·전화번호 막기, IP당 하루 20개, 같은 IP만 지우기) - 히어로·오늘의 각 카드에 좋아요·댓글 (PostType HERO·TODAY_GAK) - 히어로 오늘/내일 스위치: 내일 구간별 날씨 점수·기온·최저최고·습도·1위 각, /v1/weather/today?day=tomorrow - 단풍 지도: 단풍 그림 지도, 단풍 전·첫 단풍·절정, 단풍잎·은행잎, 명소 65곳(산림청 예측 + 가까운 지점 날짜) - 하단 탭 바 불투명 (홈 바 자리로 글이 비치지 않게) - 사람 글 동네 우선 정렬·내 글 목록, 내 각 '있는 각에서 불러오기' - 댓글 표 user_id NULL 허용·ip_hash·region_name (운영 DB ALTER 필요)
This commit is contained in:
1 parent
14f24d1ab0
commit
93e041bb91
46 files changed
+1820
-337
No files matched your search
@@ -1,10 +1,13 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
from router.router import app
|
||||
from services.talk_service import DAILY_MAX, HIDE_AT, weather_line
|
||||
from services.talk_service import DAILY_MAX, HIDE_AT, parse_cursor, spread_authors, weather_line
|
||||
|
||||
REGION = "1144000000"
|
||||
BUSAN = "2611000000"
|
||||
|
||||
|
||||
def client():
|
||||
@@ -16,8 +19,8 @@ async def _login(c, login_id: str) -> dict:
|
||||
return {"Authorization": f"Bearer {body['access_token']}"}
|
||||
|
||||
|
||||
async def _write(c, h, body="망원동 하늘 진짜 맑아요"):
|
||||
return (await c.post("/v1/talk", json={"region_code": REGION, "body": body}, headers=h)).json()
|
||||
async def _write(c, h, body="망원동 하늘 진짜 맑아요", region=REGION):
|
||||
return (await c.post("/v1/talk", json={"region_code": region, "body": body}, headers=h)).json()
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -87,3 +90,56 @@ def test_weather_line():
|
||||
assert weather_line(Row()) == "18° 맑음"
|
||||
assert weather_line(Wet()) == "12° 비"
|
||||
assert weather_line(None) is None
|
||||
|
||||
|
||||
def _ids(body: dict) -> list[int]:
|
||||
return [x["talk_id"] for x in body["talks"]]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_same_sido_talks_come_first_for_that_viewer():
|
||||
async with client() as c:
|
||||
busan = (await _write(c, await _login(c, "talk_bs1"), "광안리 바람 시원해요", BUSAN))["talk"]["talk_id"]
|
||||
seoul = (await _write(c, await _login(c, "talk_se1"), "망원동 비 그쳤어요"))["talk"]["talk_id"]
|
||||
nation = _ids((await c.get("/v1/talk/list")).json())
|
||||
local = _ids((await c.get("/v1/talk/list", params={"region": BUSAN})).json())
|
||||
assert nation.index(seoul) < nation.index(busan)
|
||||
assert local.index(busan) < local.index(seoul)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_pages_follow_cursor_without_repeats():
|
||||
async with client() as c:
|
||||
mine = []
|
||||
for i in range(5):
|
||||
h = await _login(c, f"talk_pg{i}")
|
||||
for j in range(DAILY_MAX):
|
||||
mine.append((await _write(c, h, f"페이지 글 {i}-{j}", BUSAN if j % 2 else REGION))["talk"]["talk_id"])
|
||||
seen, cursor = [], None
|
||||
while True:
|
||||
body = (await c.get("/v1/talk/list", params={"region": BUSAN} | ({"cursor": cursor} if cursor else {}))).json()
|
||||
seen += _ids(body)
|
||||
cursor = body.get("next_cursor")
|
||||
if not cursor:
|
||||
break
|
||||
assert (await c.get("/v1/talk/list", params={"cursor": "abc"})).json()["result"]["desc"] == "INVALID_INPUT"
|
||||
assert len(seen) == len(set(seen)) and set(mine) <= set(seen)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_mine_lists_only_my_talks_newest_first():
|
||||
async with client() as c:
|
||||
assert (await c.get("/v1/talk/mine")).status_code == 401
|
||||
h = await _login(c, "talk_mine")
|
||||
ids = [(await _write(c, h, f"내 글 {i}"))["talk"]["talk_id"] for i in range(3)]
|
||||
await _write(c, await _login(c, "talk_notmine"), "남의 글")
|
||||
await c.delete(f"/v1/talk/{ids[0]}", headers=h)
|
||||
body = (await c.get("/v1/talk/mine", headers=h)).json()
|
||||
assert _ids(body) == [ids[2], ids[1]] and all(x["mine"] for x in body["talks"])
|
||||
|
||||
|
||||
def test_spread_authors_and_cursor():
|
||||
v = lambda who: SimpleNamespace(author=SimpleNamespace(user_id=who)) # noqa: E731
|
||||
assert [x.author.user_id for x in spread_authors([v("a"), v("a"), v("a"), v("b"), v("c")])] == ["a", "b", "a", "c", "a"]
|
||||
assert parse_cursor("1760000000_42") == (1760000000, 42)
|
||||
assert parse_cursor("12") is None and parse_cursor("x_1") is None
|
||||
Reference in new issue
Block a user