refactor(realestate): collect_listings MOLIT 전용화(네이버는 워커 ingest로 이전)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,16 +17,18 @@ def test_parse_naver_article_fields():
|
||||
assert d["article_no"] == "A123" and d["deal_type"] == "전세" and d["deposit"] == 29000
|
||||
assert d["source"] == "naver"
|
||||
|
||||
def test_collect_naver_block_sets_naver_ok_false(monkeypatch):
|
||||
"""네이버 403 → 매물수집 skip + naver_ok=False, 실거래는 계속."""
|
||||
def test_collect_is_molit_only(monkeypatch):
|
||||
"""collect_listings는 MOLIT만 수행(naver fetch 미호출). naver는 워커 담당."""
|
||||
from app import listing_collector as lc
|
||||
monkeypatch.setattr(lc, "_fetch_molit_all", lambda: (2, "calls=1 saved=2"))
|
||||
def boom(*a, **k):
|
||||
import requests
|
||||
raise requests.RequestException("403")
|
||||
monkeypatch.setattr(lc, "_fetch_naver_all", boom)
|
||||
monkeypatch.setattr(lc, "_fetch_molit_all", lambda: (5, "calls=1 saved=5"))
|
||||
called = {"naver": False}
|
||||
def naver_spy():
|
||||
called["naver"] = True
|
||||
return (0, 0)
|
||||
monkeypatch.setattr(lc, "_fetch_naver_all", naver_spy)
|
||||
r = lc.collect_listings()
|
||||
assert r["naver_ok"] is False # 안전마진(실거래)은 유지
|
||||
assert called["naver"] is False # naver 미호출
|
||||
assert "molit" in r["diag"]
|
||||
|
||||
def test_molit_call_returns_diag_on_http_error(monkeypatch):
|
||||
"""MOLIT 401 등 HTTP 오류 → ([], diag) 반환, diag에 상태코드 포함(관측)."""
|
||||
|
||||
Reference in New Issue
Block a user