feat: 행사 카드를 최대 3장으로, 피드 사이사이 무작위 자리에

This commit is contained in:
minaChoi committed 2026-10-06 10:04:58 +09:00
1 parent d764d0e9ed
commit 75d27219ed
3 files changed
+39 -12

No files matched your search

+18
View File
@@ -109,6 +109,24 @@ def test_arrange_orders_by_slot_and_keeps_same_types_apart():
assert night[:3] == [PostType.ALERT, PostType.WEATHER, PostType.TOMORROW] and night[-1] is PostType.QUOTE
def test_arrange_scatters_up_to_three_events_same_spot_all_day():
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)
cards = [_card(t, n) for n, t in enumerate([
PostType.WEATHER, PostType.GAK, PostType.GAK, PostType.GAK, PostType.SUNSET, PostType.WEEK, PostType.SEASON,
PostType.TIP, PostType.QUOTE, PostType.EVENT, PostType.EVENT, PostType.EVENT,
])]
run = lambda h, seed: [c.post_type for c in arrange(cards, "day", datetime(2026, 10, 2, h, tzinfo=KST), sunset, False, seed)] # noqa: E731
out = run(11, "2026-10-02:1144000000")
assert out.count(PostType.EVENT) == 3 and out[0] is PostType.WEATHER
assert all(not (a is PostType.EVENT and b is PostType.EVENT) for a, b in zip(out, out[1:]))
assert run(14, "2026-10-02:1144000000") == out
@pytest.mark.anyio
async def test_build_day_makes_every_card_at_three():
thursday = date(2026, 10, 15)