diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index 1d79fb6..6063835 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -159,8 +159,8 @@ class TestRefreshListingsEndpoint: "/api/refresh_listings", params={"listing_type": "RENT"}, ) - # Should return 401 or 403 without valid auth - assert response.status_code in (401, 403) + # Should return 401/403 without valid auth, or 429 if rate-limited + assert response.status_code in (401, 403, 429) class TestTaskStatusEndpoint: diff --git a/tests/test_listing_geojson.py b/tests/test_listing_geojson.py index cfff592..c2e8536 100644 --- a/tests/test_listing_geojson.py +++ b/tests/test_listing_geojson.py @@ -100,13 +100,15 @@ class TestListingGeoJsonEndpoint: return User(sub="test-id", email="test@example.com", name="Test User") app.dependency_overrides[get_current_user] = mock_auth - yield TestClient(app) + with patch("api.rate_limiter._match_endpoint", return_value=None): + yield TestClient(app) app.dependency_overrides.clear() @pytest.fixture def mock_export(self): """Mock the export service.""" - with patch("api.app.export_service.export_to_geojson") as mock: + with patch("api.app.export_service.export_to_geojson") as mock, \ + patch("api.app._get_disliked_ids", return_value=set()): mock.return_value = MagicMock( data={"type": "FeatureCollection", "features": [{"type": "Feature"}]} ) @@ -173,6 +175,7 @@ class TestStreamingEndpoint: def mock_repository(self): """Mock the repository methods and bypass cache.""" with patch("api.app.get_cached_count", return_value=None), \ + patch("api.app._get_disliked_ids", return_value=set()), \ patch("api.app.ListingRepository") as MockRepo: mock_instance = MagicMock() mock_instance.count_listings.return_value = 3