Skip to content

Commit b84b38e

Browse files
committed
fix but where we were not explicitly specifying property types
1 parent a5d7983 commit b84b38e

File tree

4 files changed

+61
-26
lines changed

4 files changed

+61
-26
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ logging.getLogger().setLevel(logging.INFO)
9696

9797
# Changelog
9898

99+
* 2.0.3: It turns out that Evernet assumes you only want 'RESI' properties if you don't explicitly specify, so let's do so.
100+
* 2.0.2: Fixed a bug where items were not being filtered on in the `get_all_active_listings` method
101+
* 2.0.1: Fixed a bug where status wasn't being filtered correctly
99102
* 2.0.0: Add ability to filter by area and city, changed some method signatures so this is backwards-incompatible.
100103
* 1.0.1: Fix bug where the new property types weren't getting passed along
101104
* 1.0.0: Add support for different property types

evernetpy/criteria.py

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11
import itertools
22

3+
ALL_PROPERTY_TYPES = [
4+
"BUSO",
5+
"COMI",
6+
"COND",
7+
"FARM",
8+
"MANU",
9+
"MULT",
10+
"RENT",
11+
"RESI",
12+
"TSHR",
13+
"VACL",
14+
]
15+
16+
317
def iterate_criteria(begin_date, end_date, property_types=None, areas=None, cities=None, status=None):
18+
"""
19+
NOTE: If you don't pass criteria to Evernet, it will assume you only want residential properties.
20+
That's why I will iterate through all availabe types unless you pass me a list of types you want
21+
explicitly.
22+
"""
423
base_criteria = {
524
'MLS': 'nwmls',
625
'BeginDate': begin_date,
726
'EndDate': end_date,
827
}
9-
if not cities and not areas and not property_types and not status:
10-
yield base_criteria
11-
else:
12-
areas = areas or [None]
13-
cities = cities or [None]
14-
property_types = property_types or [None]
15-
status = status or [None]
16-
for property_type, area, city, status in itertools.product(property_types, areas, cities, status):
17-
criteria = {}
18-
if area:
19-
criteria['Area'] = area
20-
if city:
21-
criteria['City'] = city
22-
if status:
23-
criteria['Status'] = status
24-
if property_type:
25-
criteria['PropertyType'] = property_type
26-
criteria.update(base_criteria)
27-
yield criteria
28+
areas = areas or [None]
29+
cities = cities or [None]
30+
property_types = property_types or ALL_PROPERTY_TYPES
31+
status = status or [None]
32+
for property_type, area, city, status in itertools.product(property_types, areas, cities, status):
33+
criteria = {}
34+
if area:
35+
criteria['Area'] = area
36+
if city:
37+
criteria['City'] = city
38+
if status:
39+
criteria['Status'] = status
40+
if property_type:
41+
criteria['PropertyType'] = property_type
42+
criteria.update(base_criteria)
43+
yield criteria

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def run_tests(self):
1919
sys.exit(errno)
2020

2121
setup(name='evernetpy',
22-
version='2.0.2',
22+
version='2.0.3',
2323
description="A Python library for interacting with the EverNet listing service",
2424
author='Kevin McCarthy',
2525
author_email='[email protected]',

tests/unit/test_criteria.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22

33
def test_iterate_criteria_basic():
44
output = [x for x in iterate_criteria('foo','bar')]
5-
print output
6-
assert output == [
7-
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar'}
8-
]
5+
assert sorted(output) == sorted([
6+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'BUSO'},
7+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'COMI'},
8+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'COND'},
9+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'FARM'},
10+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'MANU'},
11+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'MULT'},
12+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'RENT'},
13+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'RESI'},
14+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'TSHR'},
15+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'VACL'},
16+
])
917

1018
def test_iterate_criteria_status():
1119
output = [x for x in iterate_criteria('foo','bar', status=['A'])]
12-
print output
1320
assert output == [
14-
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'Status': 'A'}
21+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'BUSO', 'Status': 'A'},
22+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'COMI', 'Status': 'A'},
23+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'COND', 'Status': 'A'},
24+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'FARM', 'Status': 'A'},
25+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'MANU', 'Status': 'A'},
26+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'MULT', 'Status': 'A'},
27+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'RENT', 'Status': 'A'},
28+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'RESI', 'Status': 'A'},
29+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'TSHR', 'Status': 'A'},
30+
{'MLS': 'nwmls', 'BeginDate': 'foo', 'EndDate': 'bar', 'PropertyType': 'VACL', 'Status': 'A'},
1531
]
1632

1733
def test_iterate_criteria_empty_areas():

0 commit comments

Comments
 (0)