Skip to content

Commit

Permalink
Merge pull request seme0021#17 from seme0021/more-typo-fixes
Browse files Browse the repository at this point in the history
Fix additional ``zestiamte`` typos
  • Loading branch information
jonafato committed Jan 4, 2018
2 parents 54079e8 + 9749b1c commit a217b6a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
30 changes: 28 additions & 2 deletions tests/test_valuation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import unittest
import warnings

import xmltodict
from zillow import Place

Expand All @@ -16,7 +18,7 @@ def test_search_results(self):
place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result'])

self.assertEqual("2100641621", place.zpid)
self.assertEqual(1723665, place.zestiamte.amount)
self.assertEqual(1723665, place.zestimate.amount)

def test_zestimate(self):
RAW_XML = ""
Expand All @@ -29,7 +31,31 @@ def test_zestimate(self):
place.set_data(data.get('Zestimate:zestimate', None)['response'])

self.assertEqual("2100641621", place.zpid)
self.assertEqual(1723665, place.zestiamte.amount)
self.assertEqual(1723665, place.zestimate.amount)

def test_zestiamte(self):
"""Test that the backward-compatible ``zestiamte`` works.
This property should correctly return the ``zestimate``
attribute and raise a DeprecationWarning about the changing
name.
"""
warnings.simplefilter('always', DeprecationWarning)

with open('./testdata/get_zestimate.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())

data = xmltodict.parse(RAW_XML)

place = Place()
place.set_data(data.get('Zestimate:zestimate', None)['response'])

self.assertEqual(place.zestiamte, place.zestimate)

with warnings.catch_warnings(record=True) as warning:
place.zestiamte
assert issubclass(warning[0].category, DeprecationWarning)

def test_getcomps_principal(self):
RAW_XML = ""
Expand Down
19 changes: 14 additions & 5 deletions zillow/place.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from abc import abstractmethod
import warnings


class SourceData(classmethod):

Expand Down Expand Up @@ -174,6 +176,17 @@ def __init__(self, has_extended_data=False):
self.extended_data = ExtendedData()
self.has_extended_data = has_extended_data

@property
def zestiamte(self):
"""Backward-compatible typo property to prevent breaking changes."""
warnings.warn(
'The ``zestiamte`` attribute has been renamed to '
'``zestimate`` and will be removed in a future release.',
DeprecationWarning,
)
return self.zestimate


def set_data(self, source_data):
"""
:source_data": Data from data.get('SearchResults:searchresults', None)['response']['results']['result']
Expand All @@ -185,7 +198,7 @@ def set_data(self, source_data):
self.similarity_score = source_data.get('@score', None)
self.links.set_data(source_data['links'])
self.full_address.set_data(source_data['address'])
self.zestiamte.set_data(source_data['zestimate'])
self.zestimate.set_data(source_data['zestimate'])
self.local_realestate.set_data(source_data['localRealEstate'])
if self.has_extended_data:
self.extended_data.set_data(source_data)
Expand All @@ -201,7 +214,3 @@ def get_dict(self):
'extended_data': self.extended_data.get_dict()
}
return data




0 comments on commit a217b6a

Please sign in to comment.