- 행사 수집을 화면 요청에서 빼고 worker 가 월 04:00(켤 때 7일 기록 없으면 한 번) 전국 17개 시도를 받는다 - 문화정보원 음악/콘서트(B000) 추가, 쪽·시도 사이 1초 간격으로 초당 요청 제한 회피 - 팝가(popga.co.kr) 팝업스토어 수집: 사이트맵 + 상세 JSON-LD, 바뀐 페이지만 다시 읽음 - 수집이 끝나면 Teams Workflows webhook 으로 종류별 건수 알림 (TEAMS_WEBHOOK_URL) - event.kind(1=축제 2=전시 3=콘서트 4=팝업) 칸과 종류별 아이콘 추가 - 피드 행사 카드·띠를 축제→팝업→전시→콘서트 차례로 섞음 - 포스트 종류별 내용·피드 기획 문서 갱신 같은 작업 폴더의 다른 작업(외부 API 가드, 노을·달 계산, 각 API, 문서 파일 이름 정리 등)도 함께 담김.
41 lines
2.1 KiB
Python
41 lines
2.1 KiB
Python
from datetime import datetime, timezone
|
|
from types import SimpleNamespace
|
|
|
|
from common.enums import PostType
|
|
from common.utils.kma_time import KST
|
|
from services.calc.moon import nearest, phase_name
|
|
from services.feed_service import FeedService, _tonight
|
|
|
|
|
|
def test_true_phases_match_published_times_within_five_minutes():
|
|
known = [(True, datetime(2024, 4, 23, 23, 49, tzinfo=timezone.utc)), (False, datetime(2024, 4, 8, 18, 21, tzinfo=timezone.utc)),
|
|
(True, datetime(2025, 10, 7, 3, 47, tzinfo=timezone.utc)), (False, datetime(2017, 8, 21, 18, 30, tzinfo=timezone.utc))]
|
|
for full, at in known:
|
|
assert abs((nearest(at, full) - at).total_seconds()) < 300
|
|
|
|
|
|
def test_phase_names():
|
|
assert phase_name(datetime(2025, 10, 7, 3, 47, tzinfo=timezone.utc)) == "보름달"
|
|
assert phase_name(datetime(2024, 4, 8, 18, 21, tzinfo=timezone.utc)) == "삭"
|
|
|
|
|
|
def test_tonight_follows_feed_day_starting_at_3am():
|
|
assert _tonight(datetime(2024, 4, 9, 1, 0, tzinfo=KST)) == datetime(2024, 4, 8, 22, 0, tzinfo=KST)
|
|
assert _tonight(datetime(2024, 4, 8, 20, 0, tzinfo=KST)) == datetime(2024, 4, 8, 22, 0, tzinfo=KST)
|
|
assert _tonight(datetime(2024, 4, 9, 9, 0, tzinfo=KST)) == datetime(2024, 4, 9, 22, 0, tzinfo=KST)
|
|
|
|
|
|
def _moon_post(now: datetime):
|
|
base = dict(post_id=1, post_type=PostType.MOON, like_count=0, comment_count=0, published_at=now)
|
|
c = SimpleNamespace(now=now, region=SimpleNamespace(short_name="분당구"), hourly=[], board=None)
|
|
return FeedService._moon(None, base, c)
|
|
|
|
|
|
def test_moon_post_every_night_with_full_and_new_moon_stories():
|
|
full = _moon_post(datetime(2025, 10, 7, 20, 0, tzinfo=KST)) # 보름 10.07 12:47
|
|
assert full.title == "오늘 밤 보름달" and "12:4" in full.slides[0].line
|
|
new = _moon_post(datetime(2024, 4, 9, 1, 0, tzinfo=KST)) # 삭 04.09 03:21, 자정 넘긴 새벽에도 그 밤
|
|
assert new.title == "오늘 밤 달 없는 밤"
|
|
plain = _moon_post(datetime(2025, 10, 4, 20, 0, tzinfo=KST)) # 보름 사흘 전
|
|
assert plain.title == "오늘 밤 차오르는 달" and plain.slides[0].rows[-1].label == "다음 보름" and plain.slides[0].rows[-1].value.startswith("10.07")
|