From 6632ac1669378a1302b5569d22eba087ab3a5d31 Mon Sep 17 00:00:00 2001 From: Nitzan Pomerantz <9297302+nitzpo@users.noreply.github.com> Date: Thu, 30 Oct 2025 20:54:18 +0200 Subject: [PATCH] Fix failing tests again --- nadlan_mcp/govmap/filters.py | 12 +++++------- tests/govmap/test_filters.py | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/nadlan_mcp/govmap/filters.py b/nadlan_mcp/govmap/filters.py index 6fec5a4..247b9ce 100644 --- a/nadlan_mcp/govmap/filters.py +++ b/nadlan_mcp/govmap/filters.py @@ -96,15 +96,13 @@ def filter_deals_by_criteria( # This allows "דירה" to match "דירת גג", "דירה בבניין", etc. if property_type_normalized.endswith('ה'): property_type_variant = property_type_normalized[:-1] + 'ת' - if property_type_variant 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: + if property_type_variant not in deal_type_normalized and property_type_normalized not in deal_type_normalized: # No match found for either variant continue + else: + # For non-ה endings, do substring match + if property_type_normalized not in deal_type_normalized: + continue # Room count filter if min_rooms is not None or max_rooms is not None: diff --git a/tests/govmap/test_filters.py b/tests/govmap/test_filters.py index 4d6d4b5..e34ec9d 100644 --- a/tests/govmap/test_filters.py +++ b/tests/govmap/test_filters.py @@ -167,10 +167,11 @@ class TestFilterDealsByCriteria: min_price=1000000.0, max_price=1500000.0, ) - # Should match only objectid=1 (דירה with 3 rooms, price 1M) - # objectid=2 is "דירת גג" not "דירה", so filtered out - assert len(result) == 1 - assert set(d.objectid for d in result) == {1} + # Should match objectid=1 and objectid=2 + # objectid=1: "דירה", 3 rooms, 1M price ✓ + # objectid=2: "דירת גג" (matches "דירה" variant), 4 rooms, 1.5M price ✓ + assert len(result) == 2 + assert set(d.objectid for d in result) == {1, 2} def test_filter_using_dealfilters_model(self, sample_deals): """Test filtering using DealFilters model.""" @@ -178,10 +179,11 @@ class TestFilterDealsByCriteria: property_type="דירה", min_rooms=3.0, max_rooms=4.0 ) result = filter_deals_by_criteria(sample_deals, filters=filters) - # Should match only objectid=1 (דירה with 3 rooms) - # objectid=2 is "דירת גג" not exact match - assert len(result) == 1 - assert set(d.objectid for d in result) == {1} + # Should match objectid=1 and objectid=2 + # objectid=1: "דירה", 3 rooms ✓ + # objectid=2: "דירת גג" (matches "דירה" variant), 4 rooms ✓ + assert len(result) == 2 + assert set(d.objectid for d in result) == {1, 2} def test_filter_using_dict(self, sample_deals): """Test filtering using dict (converted to DealFilters).""" @@ -191,9 +193,11 @@ class TestFilterDealsByCriteria: "max_rooms": 4.0, } result = filter_deals_by_criteria(sample_deals, filters=filters_dict) - # Should match only objectid=1 - assert len(result) == 1 - assert set(d.objectid for d in result) == {1} + # Should match objectid=1 and objectid=2 + # objectid=1: "דירה", 3 rooms ✓ + # 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): """Test that individual parameters override filters model."""