fix(realestate): listings-ingest async(BackgroundTask)+매칭/알림 타이밍 로그 + notify 홍수방지(cap+baseline)
This commit is contained in:
@@ -23,6 +23,8 @@ def test_ingest_auth(monkeypatch):
|
||||
|
||||
def test_ingest_upserts_and_matches(monkeypatch):
|
||||
c = _client(monkeypatch)
|
||||
# TestClient는 BackgroundTask를 응답 반환 전 동기 실행하므로 patch된 notify는
|
||||
# c.post()가 리턴하는 시점에 이미 호출되어 있다.
|
||||
with patch("app.internal_router.notify_new_listings", return_value={"sent": 1, "sent_ids": [1]}) as noti:
|
||||
r = c.post("/api/internal/realestate/listings-ingest",
|
||||
headers={"X-Internal-Key": "SECRET"},
|
||||
@@ -30,7 +32,7 @@ def test_ingest_upserts_and_matches(monkeypatch):
|
||||
"batches": [{"dong": "신대방동", "articles": [_ARTICLE]}]})
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["received"] == 1 and body["new"] == 1 and body["matched"] == 1
|
||||
assert body["received"] == 1 and body["new"] == 1 and body["queued"] is True
|
||||
assert noti.call_count == 1
|
||||
# 저장 확인
|
||||
from app import db
|
||||
|
||||
Reference in New Issue
Block a user