mirror of
https://github.com/Bunsly/HomeHarvest.git
synced 2026-03-04 11:34:32 -08:00
- cullen merge
This commit is contained in:
@@ -10,7 +10,6 @@ from homeharvest.exceptions import (
|
||||
def test_realtor_comps():
|
||||
result = scrape_property(
|
||||
location="2530 Al Lipscomb Way",
|
||||
site_name="realtor.com",
|
||||
radius=0.5,
|
||||
)
|
||||
|
||||
@@ -19,11 +18,11 @@ def test_realtor_comps():
|
||||
|
||||
def test_realtor_last_x_days_sold():
|
||||
days_result_30 = scrape_property(
|
||||
location="Dallas, TX", site_name="realtor.com", listing_type="sold", sold_last_x_days=30
|
||||
location="Dallas, TX", listing_type="sold", sold_last_x_days=30
|
||||
)
|
||||
|
||||
days_result_10 = scrape_property(
|
||||
location="Dallas, TX", site_name="realtor.com", listing_type="sold", sold_last_x_days=10
|
||||
location="Dallas, TX", listing_type="sold", sold_last_x_days=10
|
||||
)
|
||||
|
||||
assert all([result is not None for result in [days_result_30, days_result_10]]) and len(days_result_30) != len(days_result_10)
|
||||
@@ -33,16 +32,15 @@ def test_realtor():
|
||||
results = [
|
||||
scrape_property(
|
||||
location="2530 Al Lipscomb Way",
|
||||
site_name="realtor.com",
|
||||
listing_type="for_sale",
|
||||
),
|
||||
scrape_property(
|
||||
location="Phoenix, AZ", site_name=["realtor.com"], listing_type="for_rent"
|
||||
location="Phoenix, AZ", listing_type="for_rent"
|
||||
), #: does not support "city, state, USA" format
|
||||
scrape_property(
|
||||
location="Dallas, TX", site_name="realtor.com", listing_type="sold"
|
||||
location="Dallas, TX", listing_type="sold"
|
||||
), #: does not support "city, state, USA" format
|
||||
scrape_property(location="85281", site_name="realtor.com"),
|
||||
scrape_property(location="85281"),
|
||||
]
|
||||
|
||||
assert all([result is not None for result in results])
|
||||
@@ -52,7 +50,6 @@ def test_realtor():
|
||||
bad_results += [
|
||||
scrape_property(
|
||||
location="abceefg ju098ot498hh9",
|
||||
site_name="realtor.com",
|
||||
listing_type="for_sale",
|
||||
)
|
||||
]
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
from homeharvest import scrape_property
|
||||
from homeharvest.exceptions import (
|
||||
InvalidSite,
|
||||
InvalidListingType,
|
||||
NoResultsFound,
|
||||
GeoCoordsNotFound,
|
||||
SearchTooBroad,
|
||||
)
|
||||
|
||||
|
||||
def test_redfin():
|
||||
results = [
|
||||
scrape_property(location="San Diego", site_name="redfin", listing_type="for_sale"),
|
||||
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"),
|
||||
scrape_property(location="85281", site_name="redfin"),
|
||||
]
|
||||
|
||||
assert all([result is not None for result in results])
|
||||
|
||||
bad_results = []
|
||||
try:
|
||||
bad_results += [
|
||||
scrape_property(
|
||||
location="abceefg ju098ot498hh9",
|
||||
site_name="redfin",
|
||||
listing_type="for_sale",
|
||||
),
|
||||
scrape_property(location="Florida", site_name="redfin", listing_type="for_rent"),
|
||||
]
|
||||
except (InvalidSite, InvalidListingType, NoResultsFound, GeoCoordsNotFound, SearchTooBroad):
|
||||
assert True
|
||||
|
||||
assert all([result is None for result in bad_results])
|
||||
@@ -1,24 +0,0 @@
|
||||
from homeharvest.utils import parse_address_one, parse_address_two
|
||||
|
||||
|
||||
def test_parse_address_one():
|
||||
test_data = [
|
||||
("4303 E Cactus Rd Apt 126", ("4303 E Cactus Rd", "#126")),
|
||||
("1234 Elm Street apt 2B", ("1234 Elm Street", "#2B")),
|
||||
("1234 Elm Street UNIT 3A", ("1234 Elm Street", "#3A")),
|
||||
("1234 Elm Street unit 3A", ("1234 Elm Street", "#3A")),
|
||||
("1234 Elm Street SuIte 3A", ("1234 Elm Street", "#3A")),
|
||||
]
|
||||
|
||||
for input_data, (exp_addr_one, exp_addr_two) in test_data:
|
||||
address_one, address_two = parse_address_one(input_data)
|
||||
assert address_one == exp_addr_one
|
||||
assert address_two == exp_addr_two
|
||||
|
||||
|
||||
def test_parse_address_two():
|
||||
test_data = [("Apt 126", "#126"), ("apt 2B", "#2B"), ("UNIT 3A", "#3A"), ("unit 3A", "#3A"), ("SuIte 3A", "#3A")]
|
||||
|
||||
for input_data, expected in test_data:
|
||||
output = parse_address_two(input_data)
|
||||
assert output == expected
|
||||
@@ -1,34 +0,0 @@
|
||||
from homeharvest import scrape_property
|
||||
from homeharvest.exceptions import (
|
||||
InvalidSite,
|
||||
InvalidListingType,
|
||||
NoResultsFound,
|
||||
GeoCoordsNotFound,
|
||||
)
|
||||
|
||||
|
||||
def test_zillow():
|
||||
results = [
|
||||
scrape_property(location="2530 Al Lipscomb Way", site_name="zillow", listing_type="for_sale"),
|
||||
scrape_property(location="Phoenix, AZ, USA", site_name=["zillow"], listing_type="for_rent"),
|
||||
scrape_property(location="Surprise, AZ", site_name=["zillow"], listing_type="for_sale"),
|
||||
scrape_property(location="Dallas, TX, USA", site_name="zillow", listing_type="sold"),
|
||||
scrape_property(location="85281", site_name="zillow"),
|
||||
scrape_property(location="3268 88th st s, Lakewood", site_name="zillow", listing_type="for_rent"),
|
||||
]
|
||||
|
||||
assert all([result is not None for result in results])
|
||||
|
||||
bad_results = []
|
||||
try:
|
||||
bad_results += [
|
||||
scrape_property(
|
||||
location="abceefg ju098ot498hh9",
|
||||
site_name="zillow",
|
||||
listing_type="for_sale",
|
||||
)
|
||||
]
|
||||
except (InvalidSite, InvalidListingType, NoResultsFound, GeoCoordsNotFound):
|
||||
assert True
|
||||
|
||||
assert all([result is None for result in bad_results])
|
||||
Reference in New Issue
Block a user