Merge branch 'feat/feed-mix-talks-events' — 사람 글·행사를 피드 포스트로, 사람 글 댓글
This commit is contained in:
commit
e0c3cbf6ea
22 files changed
+653
-318
No files matched your search
@@ -195,6 +195,49 @@ def test_arrange_scatters_up_to_three_events_same_spot_all_day():
|
||||
assert run(14, "2026-10-02:1144000000") == out
|
||||
|
||||
|
||||
def test_feed_events_keeps_every_festival_and_two_of_other_kinds():
|
||||
from types import SimpleNamespace
|
||||
|
||||
from common.enums import EventKind
|
||||
from services.feed_service import feed_events
|
||||
from services.week_service import EventItem
|
||||
|
||||
kinds = [EventKind.POPUP] * 4 + [EventKind.FESTIVAL] * 6 + [EventKind.CONCERT] * 3 + [EventKind.EXHIBITION] * 3
|
||||
items = [EventItem(event=SimpleNamespace(kind=k.value, n=n), status="live", status_label="진행 중", fit=None) for n, k in enumerate(kinds)]
|
||||
out = [e.event.kind for e in feed_events(items)]
|
||||
assert out.count(EventKind.FESTIVAL.value) == 6
|
||||
assert all(out.count(k.value) == 2 for k in (EventKind.POPUP, EventKind.CONCERT, EventKind.EXHIBITION))
|
||||
assert out[:4] == [EventKind.FESTIVAL.value, EventKind.POPUP.value, EventKind.EXHIBITION.value, EventKind.CONCERT.value]
|
||||
|
||||
|
||||
def test_arrange_spreads_many_events_through_whole_feed():
|
||||
"""행사가 앞쪽 절반 자리보다 많으면 끝까지 한 장씩 걸러 끼우고, 남은 건 맨 뒤에 다 붙인다."""
|
||||
from datetime import datetime
|
||||
|
||||
from common.utils.kma_time import KST
|
||||
from services.feed_service import arrange
|
||||
|
||||
sunset = datetime(2026, 10, 2, 18, 10, tzinfo=KST)
|
||||
others = [PostType.WEATHER, PostType.GAK, PostType.GAK, PostType.GAK, PostType.SUNSET, PostType.WEEK, PostType.SEASON, PostType.TIP, PostType.QUOTE]
|
||||
cards = [_card(t, n) for n, t in enumerate(others + [PostType.EVENT] * 20)]
|
||||
out = arrange(cards, "day", datetime(2026, 10, 2, 13, tzinfo=KST), sunset, False, "2026-10-02:1144000000")
|
||||
types = [c.post_type for c in out]
|
||||
assert types.count(PostType.EVENT) == 20 and types[0] is PostType.WEATHER
|
||||
rest = len(others) - 1
|
||||
assert PostType.EVENT not in types[1:1 + 2 * rest:2] and types[2:2 + 2 * rest:2] == [PostType.EVENT] * rest
|
||||
assert set(types[1 + 2 * rest:]) == {PostType.EVENT}
|
||||
assert [c.post_id for c in out if c.post_type is PostType.EVENT] == list(range(len(others), len(others) + 20))
|
||||
|
||||
|
||||
def test_lineup_event_slots_stay_below_card_positions():
|
||||
from crud.card_crud import CARD_POSITION_START
|
||||
from services.feed_service import LINEUP, _EVENT_SLOTS
|
||||
|
||||
positions = [x[0] for x in LINEUP]
|
||||
assert len(positions) == len(set(positions)) and max(positions) < CARD_POSITION_START
|
||||
assert sorted(x[3] for x in LINEUP if x[1] is PostType.EVENT) == list(range(1, _EVENT_SLOTS + 1))
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_build_day_makes_every_card_at_three():
|
||||
thursday = date(2026, 10, 15)
|
||||
|
||||
@@ -82,6 +82,32 @@ async def test_reports_hide_and_block_hides_author():
|
||||
assert t["talk_id"] not in [x["talk_id"] for x in (await c.get("/v1/talk/list")).json()["talks"]]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_talk_comments_need_login_and_keep_count_on_talk():
|
||||
async with client() as c:
|
||||
h = await _login(c, "talk_c1")
|
||||
t = (await _write(c, h))["talk"]
|
||||
url = f"/v1/reaction/talk/{t['talk_id']}/comment"
|
||||
count = lambda talks: next(x for x in talks if x["talk_id"] == t["talk_id"])["comment_count"] # noqa: E731
|
||||
assert (await c.post(url, json={"body": "저도 봤어요"})).status_code == 401
|
||||
other = await _login(c, "talk_c2")
|
||||
assert (await c.post(url, headers=other, json={"body": "저도 봤어요"})).json()["result"]["desc"] == "TERMS_REQUIRED"
|
||||
await c.post("/v1/auth/terms", headers=other)
|
||||
assert (await c.post(url, headers=other, json={"body": "연락 010-1234-5678"})).json()["result"]["desc"] == "LINK_NOT_ALLOWED"
|
||||
assert (await c.post(url, headers=other, json={"body": "가" * 61})).json()["result"]["desc"] == "INVALID_INPUT"
|
||||
|
||||
made = (await c.post(url, headers=other, json={"body": " 저도 봤어요 "})).json()["comment"]
|
||||
assert made["body"] == "저도 봤어요" and made["mine"] is True
|
||||
listed = (await c.get(f"{url}/list")).json()["comments"]
|
||||
assert [x["comment_id"] for x in listed] == [made["comment_id"]] and listed[0]["nickname"] == "talk_c2"
|
||||
assert count((await c.get("/v1/talk/list")).json()["talks"]) == 1
|
||||
|
||||
assert (await c.delete(f"/v1/reaction/comment/{made['comment_id']}", headers=other)).json()["result"]["success"] is True
|
||||
assert (await c.get(f"{url}/list")).json()["comments"] == []
|
||||
assert count((await c.get("/v1/talk/list")).json()["talks"]) == 0
|
||||
assert (await c.post("/v1/reaction/talk/999999999/comment", headers=other, json={"body": "안녕"})).json()["result"]["desc"] == "NOT_FOUND"
|
||||
|
||||
|
||||
def test_weather_line():
|
||||
class Row:
|
||||
temp_c, sky, rain_type = 18.4, 1, 1
|
||||
|
||||
Reference in new issue
Block a user