-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathtest_valuation.py
More file actions
102 lines (71 loc) · 3.23 KB
/
test_valuation.py
File metadata and controls
102 lines (71 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import unittest
import xmltodict
from zillow import Place
class TestGetSearchResult(unittest.TestCase):
def test_search_results(self):
RAW_XML = ""
with open('./testdata/place.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())
data = xmltodict.parse(RAW_XML)
place = Place()
place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result'])
self.assertEqual("2100641621", place.zpid)
self.assertEqual(1723665, place.zestimate.amount)
def test_rent_zestimate(self):
RAW_XML = ""
with open('./testdata/rent_zestimate.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())
data = xmltodict.parse(RAW_XML)
place = Place()
place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result'])
self.assertEqual("48749425", place.zpid)
self.assertEqual(5495, place.rentzestimate.amount)
self.assertEqual(4011, place.rentzestimate.valuation_range_low)
self.assertEqual(6209, place.rentzestimate.valuation_range_high)
self.assertEqual(17, place.rentzestimate.amount_change_30days)
def test_zestimate(self):
RAW_XML = ""
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("2100641621", place.zpid)
self.assertEqual(1723665, place.zestimate.amount)
def test_getcomps_principal(self):
RAW_XML = ""
with open('./testdata/get_comps.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())
data = xmltodict.parse(RAW_XML)
place = Place()
place.set_data(data.get('Comps:comps')['response']['properties']['principal'])
self.assertEqual("2100641621", place.zpid)
def test_getcomps_comps(self):
RAW_XML = ""
with open('./testdata/get_comps.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())
data = xmltodict.parse(RAW_XML)
comps = data.get('Comps:comps')['response']['properties']['comparables']['comp']
comp_places = []
for datum in comps:
place = Place()
place.set_data(datum)
comp_places.append(place)
self.assertEqual(10, len(comp_places))
def test_extended_data(self):
RAW_XML = ""
with open('./testdata/get_deep_search_results.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())
data = xmltodict.parse(RAW_XML)
place = Place(has_extended_data=True)
place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result'])
assert place.get_dict() is not None
def test_get_deep_comps(self):
RAW_XML = ""
with open('./testdata/get_deep_comps.xml', 'r') as f:
RAW_XML = ''.join(f.readlines())
xmltodict_data = xmltodict.parse(RAW_XML)
# get the principal property data
principal_place = Place()
principal_data = xmltodict_data.get('Comps:comps')['response']['properties']['principal']
assert principal_data is not None