feat: 쇼츠 목록을 요청 때가 아니라 워커가 하루 3번(07·12·18시 10분)과 켤 때 받아 둠, 캐시는 2일 — 사용자는 유튜브 응답을 기다리지 않음
This commit is contained in:
1 parent
e0a723a3e4
commit
ba70fbcd49
4 files changed
+39
-4
No files matched your search
@@ -3,7 +3,11 @@ import json
|
||||
import httpx
|
||||
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.shorts_service import CACHE_KEY, ShortsService
|
||||
|
||||
|
||||
def test_seconds_parses_iso_duration():
|
||||
@@ -52,3 +56,18 @@ async def test_video_title_none_when_embedding_blocked():
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handle)) as client:
|
||||
assert await video_title(client, "ok") == "오늘 자전거각"
|
||||
assert await video_title(client, "blocked") is None
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_items_reads_cache_and_fetches_only_when_missing(monkeypatch):
|
||||
calls = []
|
||||
|
||||
async def fake_fetch(self, client):
|
||||
calls.append(1)
|
||||
return [{"id": "abc", "title": "오늘 자전거각"}]
|
||||
|
||||
monkeypatch.setattr(shorts_service.ShortsService, "_fetch", fake_fetch)
|
||||
await REDIS.conn.delete(CACHE_KEY)
|
||||
assert await ShortsService().items() == (ErrorType.SUCCESS, [{"id": "abc", "title": "오늘 자전거각"}])
|
||||
assert await ShortsService().items() == (ErrorType.SUCCESS, [{"id": "abc", "title": "오늘 자전거각"}])
|
||||
assert len(calls) == 1
|
||||
Reference in new issue
Block a user