From 68a3438c6ee6b68cc5e1ddceb9aaccf50025e590 Mon Sep 17 00:00:00 2001 From: zachary Date: Mon, 5 May 2025 12:29:36 -0700 Subject: [PATCH] - single home return type bug fix --- homeharvest/core/scrapers/realtor/__init__.py | 5 ++++- pyproject.toml | 2 +- tests/test_realtor.py | 15 +++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/homeharvest/core/scrapers/realtor/__init__.py b/homeharvest/core/scrapers/realtor/__init__.py index 64f0a23..a89fcfa 100644 --- a/homeharvest/core/scrapers/realtor/__init__.py +++ b/homeharvest/core/scrapers/realtor/__init__.py @@ -121,7 +121,10 @@ class RealtorScraper(Scraper): property_info = response_json["data"]["home"] - return [self.process_property(property_info)] + if self.return_type != ReturnType.raw: + return [self.process_property(property_info)] + else: + return [property_info] @staticmethod def process_advertisers(advertisers: list[dict] | None) -> Advertisers | None: diff --git a/pyproject.toml b/pyproject.toml index f60c2c6..346873e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "homeharvest" -version = "0.4.8" +version = "0.4.9" description = "Real estate scraping library" authors = ["Zachary Hampton ", "Cullen Watson "] homepage = "https://github.com/Bunsly/HomeHarvest" diff --git a/tests/test_realtor.py b/tests/test_realtor.py index 82b49cd..c2bc713 100644 --- a/tests/test_realtor.py +++ b/tests/test_realtor.py @@ -292,11 +292,14 @@ def test_phone_number_matching(): def test_return_type(): results = { - "pandas": scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100), - "pydantic": scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="pydantic"), - "raw": scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="raw"), + "pandas": [scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100)], + "pydantic": [scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="pydantic")], + "raw": [ + scrape_property(location="Surprise, AZ", listing_type="for_rent", limit=100, return_type="raw"), + scrape_property(location="66642", listing_type="for_rent", limit=100, return_type="raw"), + ], } - assert isinstance(results["pandas"], pd.DataFrame) - assert isinstance(results["pydantic"][0], Property) - assert isinstance(results["raw"][0], dict) + assert all(isinstance(result, pd.DataFrame) for result in results["pandas"]) + assert all(isinstance(result[0], Property) for result in results["pydantic"]) + assert all(isinstance(result[0], dict) for result in results["raw"])