Fix failing tests again
This commit is contained in:
@@ -96,15 +96,13 @@ def filter_deals_by_criteria(
|
|||||||
# This allows "דירה" to match "דירת גג", "דירה בבניין", etc.
|
# This allows "דירה" to match "דירת גג", "דירה בבניין", etc.
|
||||||
if property_type_normalized.endswith('ה'):
|
if property_type_normalized.endswith('ה'):
|
||||||
property_type_variant = property_type_normalized[:-1] + 'ת'
|
property_type_variant = property_type_normalized[:-1] + 'ת'
|
||||||
if property_type_variant in deal_type_normalized:
|
if property_type_variant not in deal_type_normalized and property_type_normalized not in deal_type_normalized:
|
||||||
# Found variant match, continue to next filter
|
|
||||||
pass
|
|
||||||
elif property_type_normalized in deal_type_normalized:
|
|
||||||
# Found original match, continue to next filter
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# No match found for either variant
|
# No match found for either variant
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
# For non-ה endings, do substring match
|
||||||
|
if property_type_normalized not in deal_type_normalized:
|
||||||
|
continue
|
||||||
|
|
||||||
# Room count filter
|
# Room count filter
|
||||||
if min_rooms is not None or max_rooms is not None:
|
if min_rooms is not None or max_rooms is not None:
|
||||||
|
|||||||
@@ -167,10 +167,11 @@ class TestFilterDealsByCriteria:
|
|||||||
min_price=1000000.0,
|
min_price=1000000.0,
|
||||||
max_price=1500000.0,
|
max_price=1500000.0,
|
||||||
)
|
)
|
||||||
# Should match only objectid=1 (דירה with 3 rooms, price 1M)
|
# Should match objectid=1 and objectid=2
|
||||||
# objectid=2 is "דירת גג" not "דירה", so filtered out
|
# objectid=1: "דירה", 3 rooms, 1M price ✓
|
||||||
assert len(result) == 1
|
# objectid=2: "דירת גג" (matches "דירה" variant), 4 rooms, 1.5M price ✓
|
||||||
assert set(d.objectid for d in result) == {1}
|
assert len(result) == 2
|
||||||
|
assert set(d.objectid for d in result) == {1, 2}
|
||||||
|
|
||||||
def test_filter_using_dealfilters_model(self, sample_deals):
|
def test_filter_using_dealfilters_model(self, sample_deals):
|
||||||
"""Test filtering using DealFilters model."""
|
"""Test filtering using DealFilters model."""
|
||||||
@@ -178,10 +179,11 @@ class TestFilterDealsByCriteria:
|
|||||||
property_type="דירה", min_rooms=3.0, max_rooms=4.0
|
property_type="דירה", min_rooms=3.0, max_rooms=4.0
|
||||||
)
|
)
|
||||||
result = filter_deals_by_criteria(sample_deals, filters=filters)
|
result = filter_deals_by_criteria(sample_deals, filters=filters)
|
||||||
# Should match only objectid=1 (דירה with 3 rooms)
|
# Should match objectid=1 and objectid=2
|
||||||
# objectid=2 is "דירת גג" not exact match
|
# objectid=1: "דירה", 3 rooms ✓
|
||||||
assert len(result) == 1
|
# objectid=2: "דירת גג" (matches "דירה" variant), 4 rooms ✓
|
||||||
assert set(d.objectid for d in result) == {1}
|
assert len(result) == 2
|
||||||
|
assert set(d.objectid for d in result) == {1, 2}
|
||||||
|
|
||||||
def test_filter_using_dict(self, sample_deals):
|
def test_filter_using_dict(self, sample_deals):
|
||||||
"""Test filtering using dict (converted to DealFilters)."""
|
"""Test filtering using dict (converted to DealFilters)."""
|
||||||
@@ -191,9 +193,11 @@ class TestFilterDealsByCriteria:
|
|||||||
"max_rooms": 4.0,
|
"max_rooms": 4.0,
|
||||||
}
|
}
|
||||||
result = filter_deals_by_criteria(sample_deals, filters=filters_dict)
|
result = filter_deals_by_criteria(sample_deals, filters=filters_dict)
|
||||||
# Should match only objectid=1
|
# Should match objectid=1 and objectid=2
|
||||||
assert len(result) == 1
|
# objectid=1: "דירה", 3 rooms ✓
|
||||||
assert set(d.objectid for d in result) == {1}
|
# objectid=2: "דירת גג" (matches "דירה" variant), 4 rooms ✓
|
||||||
|
assert len(result) == 2
|
||||||
|
assert set(d.objectid for d in result) == {1, 2}
|
||||||
|
|
||||||
def test_individual_params_override_filters_model(self, sample_deals):
|
def test_individual_params_override_filters_model(self, sample_deals):
|
||||||
"""Test that individual parameters override filters model."""
|
"""Test that individual parameters override filters model."""
|
||||||
|
|||||||
Reference in New Issue
Block a user