fix: df3fba7 에 섞여 들어간 옛 파일 되돌림 — 쇼츠 RSS·사주 생년월일 저장·생성 API 클라이언트를 ca6d55f 상태로

This commit is contained in:
minaChoi committed 2026-10-29 09:14:04 +09:00
1 parent cf7c96eaff
commit 051452d3b1
21 files changed
+865 -311

No files matched your search

+27 -1
View File
@@ -37,6 +37,8 @@ async def test_reading_for_anyone_gives_me_today_and_cards(offline):
assert r["me"]["scene"].endswith("기운") and r["today"]["title"] and 0 <= r["today"]["score"] <= 100
kinds = [x["kind"] for x in r["today"]["cards"]]
assert "when" in kinds and "do" in kinds and "wear" in kinds
# 근거 줄은 쉬운 말 + 괄호 용어, 숫자 없이
assert r["today"]["why"] and not any(ch.isdigit() for w in r["today"]["why"] for ch in w)
# 로그인 안 하면 레벨로 여는 것은 모두 잠김, 내용도 안 옴
assert r["logged_in"] is False and all(not x["unlocked"] for x in r["locks"])
assert "week" not in r and "love" not in r and "money" not in r
@@ -68,7 +70,7 @@ async def test_level_unlocks_sections_and_awards_once(offline):
h7 = await _login(c, "saju_07", points=1000)
r = (await c.post("/v1/saju/reading", json=BIRTH, headers=h7)).json()
assert r["month"]["title"].endswith("달") and "년" in r["year"]["label"] and len(r["year"]["months"]) == 3
assert r["month"]["title"].endswith("달") and "년" in r["year"]["label"] and 1 <= len(r["year"]["months"]) <= 3
@pytest.mark.anyio
@@ -81,3 +83,27 @@ async def test_match_needs_level_five(offline):
h5 = await _login(c, "match_05", points=400)
m = (await c.post("/v1/saju/match", json=body, headers=h5)).json()
assert m["title"].endswith("사이") and m["lines"] and 0 <= m["score"] <= 100 and m["day"]["weekday"] and m["friend_scene"].endswith("기운")
@pytest.mark.anyio
async def test_match_score_is_same_whoever_goes_first(offline):
a, b = {"birth_date": "1995-03-14"}, {"birth_date": "1996-11-02"}
async with client() as c:
h = await _login(c, "match_sym", points=400)
ab = (await c.post("/v1/saju/match", json={"region_code": REGION, "me": a, "friend": b}, headers=h)).json()
ba = (await c.post("/v1/saju/match", json={"region_code": REGION, "me": b, "friend": a}, headers=h)).json()
assert ab["score"] == ba["score"]
@pytest.mark.anyio
async def test_birth_is_saved_to_account(offline):
body = {"birth_date": "1995-03-14", "birth_time": "07:30", "place": "busan", "gender": "female"}
async with client() as c:
assert (await c.get("/v1/saju/birth")).status_code == 401
h = await _login(c, "birth_01")
assert "birth" not in (await c.get("/v1/saju/birth", headers=h)).json()
assert (await c.put("/v1/saju/birth", json=body, headers=h)).json()["birth"] == body
assert (await c.get("/v1/saju/birth", headers=h)).json()["birth"] == body
assert (await c.put("/v1/saju/birth", json={**body, "birth_date": "1899-12-31"}, headers=h)).json()["result"]["desc"] == "INVALID_INPUT"
await c.delete("/v1/saju/birth", headers=h)
assert "birth" not in (await c.get("/v1/saju/birth", headers=h)).json()
+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 = []