- 내 각: 아이콘 고르기(my_gak.icon), 카드는 아이콘·점수·아쉬운 조건만, 눌러서 상세(시간대·조건별 점수), 공유는 공통 공유 창 - 이야기: 오늘 쓴 내 글 묶음, '내 글' 칩·탭, 무한 스크롤, 사진 카메라 버튼, 지우기 확인, ⋯ 메뉴 하트 옆, 글 시간 서버 계산(1일 전) - 공유 이미지: 1:1·4:5 는 아래 얇은 띠 한 줄로 카드를 크게 - 행사: 수집 때 주소 저장(event.address), 행사 포스트에 장소·주소·기간 - 히어로 말풍선 '오늘 낮은 / 내일 낮은', 내일을 볼 때 배경도 따라감, 달 보름 순간이 낮이면 뜨는 시각으로 - 단풍 지도 피드 맨 위, 행사·계절 띠 포스트 틀 되돌림, 쇼츠 홈 버튼 가림·닫기 버튼, 하단 여백, 회색 글자 대비 - 토스 앱에선 쇼츠 플레이어를 하나만 띄움
75 lines
4.0 KiB
Python
75 lines
4.0 KiB
Python
import json
|
|
from datetime import date
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
from common.enums import EventKind
|
|
from services.external import popga
|
|
from services.external.popga import fetch_popup_index, parse_popup, sido_of
|
|
|
|
|
|
def _page(popup_id: int, kind: str, start: str, end: str, address: str = "서울 성동구 테스트로 1") -> str:
|
|
ld = {
|
|
"@context": "https://schema.org", "@type": "Event", "name": "테스트 팝업 & 굿즈", "startDate": start, "endDate": end,
|
|
"location": {"@type": "Place", "name": "테스트 빌딩 1F", "address": {"@type": "PostalAddress", "streetAddress": address},
|
|
"geo": {"@type": "GeoCoordinates", "latitude": 37.5446123, "longitude": 127.0557456}},
|
|
}
|
|
payload = f'self.__next_f.push([1,"{{\\"data\\":{{\\"id\\":{popup_id},\\"type\\":\\"{kind}\\",\\"source\\":null}}}}"])'
|
|
return f'<html><script type="application/ld+json">{json.dumps(ld, ensure_ascii=False)}</script><script>{payload}</script></html>'
|
|
|
|
|
|
def test_parse_popup_maps_store():
|
|
row = parse_popup(_page(501, "STORE", "2026-10-02", "2026-10-11"), 501, date(2026, 10, 1))
|
|
assert row == {
|
|
"source_id": "popga:501", "sido_code": "11", "name": "테스트 팝업 & 굿즈", "place_name": "테스트 빌딩 1F", "address": "서울 성동구 테스트로 1",
|
|
"start_date": date(2026, 10, 2), "end_date": date(2026, 10, 11), "is_confirmed": True,
|
|
"source_url": "https://popga.co.kr/popup/501", "image_url": None, "lat": 37.54461, "lon": 127.05575, "kind": EventKind.POPUP, "icon": "popup",
|
|
}
|
|
|
|
|
|
def test_parse_popup_maps_festival():
|
|
row = parse_popup(_page(504, "FESTIVAL", "2026-10-02", "2026-10-11", "경기 수원시 팔달구 테스트로 1"), 504, date(2026, 10, 1))
|
|
assert (row["kind"], row["icon"], row["sido_code"]) == (EventKind.FESTIVAL, "fireworks", "41")
|
|
|
|
|
|
def test_parse_popup_moves_festival_shows_in_theaters_to_concert():
|
|
page = _page(505, "FESTIVAL", "2026-10-02", "2026-10-11").replace("테스트 빌딩 1F", "대학로예술극장 소극장")
|
|
assert parse_popup(page, 505, date(2026, 10, 1))["kind"] is EventKind.CONCERT
|
|
|
|
|
|
@pytest.mark.parametrize("kind,end,address", [
|
|
("PERFORMANCE", "2026-10-11", "서울 성동구 테스트로 1"),
|
|
("STORE", "2026-09-30", "서울 성동구 테스트로 1"),
|
|
("STORE", "2026-10-11", "알 수 없는 주소"),
|
|
])
|
|
def test_parse_popup_skips_non_store_ended_or_unknown_sido(kind, end, address):
|
|
assert parse_popup(_page(502, kind, "2026-09-01", end, address), 502, date(2026, 10, 1)) is None
|
|
|
|
|
|
def test_parse_popup_reads_type_of_its_own_id():
|
|
page = _page(503, "STORE", "2026-10-02", "2026-10-11").replace('\\"id\\":503,\\"type\\":\\"STORE\\"', '\\"id\\":999,\\"type\\":\\"STORE\\"')
|
|
assert parse_popup(page, 503, date(2026, 10, 1)) is None
|
|
|
|
|
|
@pytest.mark.parametrize("address,code", [
|
|
("서울 마포구 테스트로 1", "11"), ("서울특별시 마포구", "11"), ("경기 수원시", "41"), ("경상남도 진주시", "48"),
|
|
("강원특별자치도 춘천시", "51"), ("전북특별자치도 전주시", "52"), ("", None),
|
|
])
|
|
def test_sido_of(address, code):
|
|
assert sido_of(address) == code
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_fetch_popup_index_reads_popup_pages_only(monkeypatch):
|
|
monkeypatch.setattr(popga, "REQUEST_GAP_SEC", 0)
|
|
pages = {
|
|
"/sitemap.xml": "<sitemapindex><sitemap><loc>https://popga.co.kr/sitemap/2.xml</loc></sitemap>"
|
|
"<sitemap><loc>https://popga.co.kr/sitemap/5.xml</loc></sitemap></sitemapindex>",
|
|
"/sitemap/2.xml": "<urlset><url><loc>https://popga.co.kr/popup/12</loc><lastmod>2026-10-06T00:00:00Z</lastmod></url>"
|
|
"<url><loc>https://popga.co.kr/popup/11</loc></url></urlset>",
|
|
"/sitemap/5.xml": "<urlset><url><loc>https://popga.co.kr/popup/12/review/3</loc><lastmod>2026-10-06</lastmod></url></urlset>",
|
|
}
|
|
async with httpx.AsyncClient(transport=httpx.MockTransport(lambda req: httpx.Response(200, text=pages[req.url.path]))) as client:
|
|
assert await fetch_popup_index(client) == {12: "2026-10-06T00:00:00Z", 11: ""}
|