2023-09-15 15:17:37 -07:00
|
|
|
from homeharvest import scrape_property
|
2023-09-18 20:59:49 -07:00
|
|
|
from homeharvest.exceptions import (
|
|
|
|
InvalidSite,
|
|
|
|
InvalidListingType,
|
|
|
|
NoResultsFound,
|
|
|
|
GeoCoordsNotFound,
|
|
|
|
)
|
2023-09-15 15:17:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_redfin():
|
2023-09-16 13:39:03 -07:00
|
|
|
results = [
|
2023-09-19 19:13:20 -07:00
|
|
|
scrape_property(location="2530 Al Lipscomb Way", site_name="redfin", listing_type="for_sale"),
|
|
|
|
scrape_property(location="Phoenix, AZ, USA", site_name=["redfin"], listing_type="for_rent"),
|
|
|
|
scrape_property(location="Dallas, TX, USA", site_name="redfin", listing_type="sold"),
|
2023-09-17 13:06:31 -07:00
|
|
|
scrape_property(location="85281", site_name="redfin"),
|
2023-09-16 13:39:03 -07:00
|
|
|
]
|
2023-09-15 15:17:37 -07:00
|
|
|
|
2023-09-16 13:39:03 -07:00
|
|
|
assert all([result is not None for result in results])
|
2023-09-18 20:28:03 -07:00
|
|
|
|
|
|
|
bad_results = []
|
|
|
|
try:
|
|
|
|
bad_results += [
|
|
|
|
scrape_property(
|
|
|
|
location="abceefg ju098ot498hh9",
|
|
|
|
site_name="redfin",
|
|
|
|
listing_type="for_sale",
|
|
|
|
)
|
|
|
|
]
|
|
|
|
except (InvalidSite, InvalidListingType, NoResultsFound, GeoCoordsNotFound):
|
|
|
|
assert True
|
|
|
|
|
|
|
|
assert all([result is None for result in bad_results])
|