feat(realestate-matcher): 5-tier district weighting + eligibility curve
지역 점수를 35점(광역 10 + 자치구 S/A/B/C/D 티어 0~25)으로 재배분하고, 자격 점수를 25점(첫 자격 15 + 추가당 5, 최대 +10) 곡선으로 변경. 총점 구성: 지역 35 + 유형 10 + 면적 15 + 가격 15 + 자격 25 = 100. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
83
realestate-lab/tests/test_matcher.py
Normal file
83
realestate-lab/tests/test_matcher.py
Normal file
@@ -0,0 +1,83 @@
|
||||
def test_region_score_no_districts_full_when_region_match():
|
||||
"""자치구 미설정: 광역 일치 시 35점."""
|
||||
from app.matcher import _region_score
|
||||
profile = {"preferred_regions": ["서울"], "preferred_districts": {}}
|
||||
ann = {"region_name": "서울특별시", "district": None}
|
||||
score, _ = _region_score(profile, ann)
|
||||
assert score == 35
|
||||
|
||||
|
||||
def test_region_score_no_districts_zero_when_region_mismatch():
|
||||
from app.matcher import _region_score
|
||||
profile = {"preferred_regions": ["서울"], "preferred_districts": {}}
|
||||
ann = {"region_name": "부산광역시", "district": None}
|
||||
score, _ = _region_score(profile, ann)
|
||||
assert score == 0
|
||||
|
||||
|
||||
def test_region_score_s_tier_district():
|
||||
"""광역 매칭 + S티어 자치구: 10 + 25 = 35."""
|
||||
from app.matcher import _region_score
|
||||
profile = {
|
||||
"preferred_regions": ["서울"],
|
||||
"preferred_districts": {"S": ["강남구"], "A": [], "B": [], "C": [], "D": []},
|
||||
}
|
||||
ann = {"region_name": "서울특별시", "district": "강남구"}
|
||||
score, _ = _region_score(profile, ann)
|
||||
assert score == 35
|
||||
|
||||
|
||||
def test_region_score_a_tier_district():
|
||||
"""광역 매칭 + A티어 자치구: 10 + 20 = 30."""
|
||||
from app.matcher import _region_score
|
||||
profile = {
|
||||
"preferred_regions": ["서울"],
|
||||
"preferred_districts": {"S": [], "A": ["송파구"], "B": [], "C": [], "D": []},
|
||||
}
|
||||
ann = {"region_name": "서울특별시", "district": "송파구"}
|
||||
score, _ = _region_score(profile, ann)
|
||||
assert score == 30
|
||||
|
||||
|
||||
def test_region_score_d_tier_district():
|
||||
"""광역 매칭 + D티어 자치구: 10 + 5 = 15."""
|
||||
from app.matcher import _region_score
|
||||
profile = {
|
||||
"preferred_regions": ["서울"],
|
||||
"preferred_districts": {"S": [], "A": [], "B": [], "C": [], "D": ["도봉구"]},
|
||||
}
|
||||
ann = {"region_name": "서울특별시", "district": "도봉구"}
|
||||
score, _ = _region_score(profile, ann)
|
||||
assert score == 15
|
||||
|
||||
|
||||
def test_region_score_district_set_but_not_listed():
|
||||
"""광역 매칭 + 자치구 5티어 어디에도 없음: 10점만."""
|
||||
from app.matcher import _region_score
|
||||
profile = {
|
||||
"preferred_regions": ["서울"],
|
||||
"preferred_districts": {"S": ["강남구"], "A": [], "B": [], "C": [], "D": []},
|
||||
}
|
||||
ann = {"region_name": "서울특별시", "district": "강서구"}
|
||||
score, _ = _region_score(profile, ann)
|
||||
assert score == 10
|
||||
|
||||
|
||||
def test_eligibility_score_zero_when_empty():
|
||||
from app.matcher import _eligibility_score
|
||||
assert _eligibility_score([]) == 0
|
||||
|
||||
|
||||
def test_eligibility_score_one_type_returns_15():
|
||||
from app.matcher import _eligibility_score
|
||||
assert _eligibility_score(["일반1순위"]) == 15
|
||||
|
||||
|
||||
def test_eligibility_score_two_types_returns_20():
|
||||
from app.matcher import _eligibility_score
|
||||
assert _eligibility_score(["일반1순위", "특별-신혼부부"]) == 20
|
||||
|
||||
|
||||
def test_eligibility_score_caps_at_25():
|
||||
from app.matcher import _eligibility_score
|
||||
assert _eligibility_score(["a", "b", "c", "d", "e"]) == 25
|
||||
Reference in New Issue
Block a user