Skip to content

Commit

Permalink
Support API error 6 (#29)
Browse files Browse the repository at this point in the history
* handling error 6

* linter
  • Loading branch information
hanneshapke committed May 31, 2020
1 parent c84a547 commit eae48d8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyzillow/pyzillowerrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ZillowError(Exception):
+ "The Zillow Web Service is currently not available. "
+ "Please come back later and try again.",
),
(6, "This account is not authorized to execute this API call."),
(7, "Too many requests. \n" + "Daily requests exceeded.",),
(
500,
Expand Down
1 change: 1 addition & 0 deletions test/api_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"get_deep_search_200_ok": "get_deep_search_200_ok.xml",
"updated_property_details_200_ok": "updated_property_details_200_ok.xml",
"error_2_zwsid_missing": "error_2_zwsid_missing.xml",
"error_6_account_not_authorized": "error_6_account_not_authorized.xml",
"error_500_no_address_provided": "error_500.xml",
"error_501_no_city_state": "error_501.xml",
"error_508_invalid_address": "error_508_invalid_address.xml",
Expand Down
20 changes: 20 additions & 0 deletions test/test_pyzillow.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ def test_zillow_error_no_coverage(self):
error_msg = "Status 508: No exact match found for input address."
assert error_msg in str(excinfo.value)

@responses.activate
def test_zillow_error_account_not_authorized(self):
"""
This test checks for account not authorized error
Expected error code: 6
"""

set_get_deep_search_response(
self.api_response_obj.get("error_6_account_not_authorized")
)

zillow_data = ZillowWrapper(self.ZILLOW_API_KEY)

with pytest.raises(ZillowError) as excinfo:
zillow_data.get_deep_search_results(
address=self.address, zipcode=self.zipcode
)
error_msg = "Status 6: This account is not authorized to execute this API call"
assert error_msg in str(excinfo.value)

@responses.activate
def test_deep_search_results(self):
"""
Expand Down
13 changes: 13 additions & 0 deletions test/xml_payloads/error_6_account_not_authorized.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.com/vstatic/80d5e73/static/xsd/SearchResults.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SearchResults="http://www.zillow.com/static/xsd/SearchResults.xsd">
<request>
<address>2114 Bigelow Ave Seattle, WA</address>
<citystatezip>98109</citystatezip>
</request>
<message>
<text>Error: this account is not authorized to execute this API call</text>
<code>6</code>
</message>
</SearchResults:searchresults><!-- H:002 T:1ms S:150 R:Fri May 29 11:15:27 PDT 2020 B:5.0.65042-master.b06afcd~delivery_ready.c5a1f6a9 -->

0 comments on commit eae48d8

Please sign in to comment.