feat(realestate-profile): expose 5tier districts + min_match_score + notify_enabled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from typing import Optional, List
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, List, Dict
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class AnnouncementCreate(BaseModel):
|
||||
@@ -80,3 +80,7 @@ class ProfileUpdate(BaseModel):
|
||||
min_area: Optional[float] = None
|
||||
max_area: Optional[float] = None
|
||||
max_price: Optional[int] = None
|
||||
# 신규
|
||||
preferred_districts: Optional[Dict[str, List[str]]] = None
|
||||
min_match_score: Optional[int] = Field(default=None, ge=0, le=100)
|
||||
notify_enabled: Optional[bool] = None
|
||||
|
||||
42
realestate-lab/tests/test_profile_api.py
Normal file
42
realestate-lab/tests/test_profile_api.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_profile_update_accepts_new_fields():
|
||||
from app.main import app
|
||||
body = {
|
||||
"name": "테스트",
|
||||
"preferred_districts": {
|
||||
"S": ["강남구", "서초구"],
|
||||
"A": ["송파구"],
|
||||
"B": [],
|
||||
"C": [],
|
||||
"D": [],
|
||||
},
|
||||
"min_match_score": 75,
|
||||
"notify_enabled": True,
|
||||
}
|
||||
with TestClient(app) as client:
|
||||
resp = client.put("/api/realestate/profile", json=body)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["preferred_districts"]["S"] == ["강남구", "서초구"]
|
||||
assert data["min_match_score"] == 75
|
||||
assert data["notify_enabled"] is True
|
||||
|
||||
|
||||
def test_profile_get_returns_defaults_for_new_fields():
|
||||
from app.main import app
|
||||
from app.db import upsert_profile, _conn
|
||||
|
||||
# 이전 테스트 데이터 제거 후 새 프로필 삽입
|
||||
with _conn() as conn:
|
||||
conn.execute("DELETE FROM user_profile")
|
||||
upsert_profile({"name": "기본"})
|
||||
|
||||
with TestClient(app) as client:
|
||||
resp = client.get("/api/realestate/profile")
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["preferred_districts"] == {}
|
||||
assert data["min_match_score"] == 70
|
||||
assert data["notify_enabled"] is True
|
||||
Reference in New Issue
Block a user