Merge remote-tracking branch 'origin/main' into feat/weather-saju

# Conflicts:
#	shared/api/client/@tanstack/react-query.gen.ts
#	shared/api/client/index.ts
#	shared/api/client/sdk.gen.ts
This commit is contained in:
minaChoi committed 2026-10-28 17:17:57 +09:00
commit c61d488794
17 files changed
+469 -126

No files matched your search

+39
View File
@@ -102,3 +102,42 @@ async def test_seven_day_attendance_bonus(offline):
me = (await c.post("/v1/level/attend", headers=h)).json()
# 지난 6일은 장부만 넣어 총량엔 없다: 오늘 출석 10 + 7일 연속 50
assert me["streak"] == 7 and me["points"] == 60
@pytest.mark.anyio
async def test_game_rounds_award_two_each_up_to_twenty(offline):
import time
from services.level_service import GAME_ROUND_MIN_SEC, game_token
async with client() as c:
h = await _login(c, "level_03")
other = await _login(c, "level_04")
uid = await DB_SESSION_MNG.execute_lambda(lambda s: s.scalar(select(User.user_id).where(User.login_id == "level_03")))
uid = uid[1]
play = (await c.post("/v1/level/game/start", headers=h)).json()["play"]
# 시작하자마자 깬 라운드는 받지 않는다
me = (await c.post("/v1/level/game/round", json={"play": play, "round": 1}, headers=h)).json()
assert _earned(me, "game") == 0
# 충분히 지난 판: 라운드마다 2각, 같은 라운드는 한 번
old = game_token(uid, int(time.time()) - GAME_ROUND_MIN_SEC * 30)
await c.post("/v1/level/game/round", json={"play": old, "round": 1}, headers=h)
me = (await c.post("/v1/level/game/round", json={"play": old, "round": 1}, headers=h)).json()
assert _earned(me, "game") == 2 and me["points"] == 2
# 남의 판·위조한 판은 받지 않는다
me = (await c.post("/v1/level/game/round", json={"play": old, "round": 2}, headers=other)).json()
assert _earned(me, "game") == 0
forged = old.split(".")[0] + ".0000000000000000"
me = (await c.post("/v1/level/game/round", json={"play": forged, "round": 2}, headers=h)).json()
assert _earned(me, "game") == 2
# 하루 20각까지
for r in range(2, 15):
me = (await c.post("/v1/level/game/round", json={"play": old, "round": r}, headers=h)).json()
assert _earned(me, "game") == 20 and me["points"] == 20
# 로그인 안 하면 판을 열 수 없다
assert (await c.post("/v1/level/game/start")).status_code == 401
+27 -1
View File
@@ -6,7 +6,7 @@ import pytest
from common.cache.redis_client import REDIS
from common.enums import ErrorType
from services import shorts_service
from services.external.youtube import channel_shorts, seconds, video_title
from services.external.youtube import channel_shorts, feed_shorts, seconds, video_title
from services.shorts_service import CACHE_KEY, ShortsService
@@ -58,6 +58,32 @@ async def test_video_title_none_when_embedding_blocked():
assert await video_title(client, "blocked") is None
def _feed(entries: list[tuple[str, str]]) -> str:
items = "".join(
f"<entry><yt:videoId>{vid}</yt:videoId><title>제목 {vid}</title><published>{published}</published></entry>" for vid, published in entries
)
return f'<feed xmlns="http://www.w3.org/2005/Atom" xmlns:yt="http://www.youtube.com/xml/schemas/2015">{items}</feed>'
@pytest.mark.anyio
async def test_feed_shorts_reads_channel_shorts_feed_newest_first_without_blocked():
seen = {}
def handle(req: httpx.Request) -> httpx.Response:
if req.url.path.endswith("/feeds/videos.xml"):
seen["playlist"] = req.url.params["playlist_id"]
return httpx.Response(200, text=_feed([("old", "2026-10-20T00:00:00+00:00"), ("new", "2026-10-28T00:00:00+00:00"), ("blocked", "2026-10-27T00:00:00+00:00")]))
if "blocked" in req.url.params["url"]:
return httpx.Response(401)
return httpx.Response(200, content=json.dumps({"title": "x"}))
async with httpx.AsyncClient(transport=httpx.MockTransport(handle)) as client:
found = await feed_shorts(client, "UCtest", 10)
assert seen["playlist"] == "UUSHtest"
assert [v["id"] for v in found] == ["new", "old"]
assert found[0]["title"] == "제목 new"
@pytest.mark.anyio
async def test_items_reads_cache_and_fetches_only_when_missing(monkeypatch):
calls = []