fix: 쇼츠 줄을 고정 영상 ID 대신 채널 쇼츠 RSS로 — API 키가 없어도 새 쇼츠가 자동으로 붙게, youtube_shorts 설정 삭제
This commit is contained in:
1 parent
c8df1f5ef6
commit
4d79ec839c
6 files changed
+55
-13
No files matched your search
@@ -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 = []
|
||||
|
||||
Reference in new issue
Block a user