diff --git a/src/meshapi/tests/test_validation.py b/src/meshapi/tests/test_validation.py index bcf297d5..56484ec0 100644 --- a/src/meshapi/tests/test_validation.py +++ b/src/meshapi/tests/test_validation.py @@ -11,7 +11,7 @@ class TestValidationNYCAddressInfo(TestCase): def test_invalid_state(self): with self.assertRaises(ValueError): - NYCAddressInfo("151 Broome St", "New York", "ny", 10002) + NYCAddressInfo("151 Broome St", "New York", "ny", "10002") @patch("meshapi.validation.requests.get") def test_validate_address_geosearch_unexpected_responses(self, mock_requests): @@ -29,12 +29,12 @@ def test_validate_address_geosearch_unexpected_responses(self, mock_requests): for test_case in test_cases: with self.assertRaises(test_case["exception"]): mock_requests.return_value = test_case["mock"] - NYCAddressInfo("151 Broome St", "New York", "NY", 10002) + NYCAddressInfo("151 Broome St", "New York", "NY", "10002") @patch("meshapi.validation.requests.get", side_effect=Exception("Pretend this is a network issue")) def test_validate_address_geosearch_network(self, mock_requests): with self.assertRaises(AddressAPIError): - NYCAddressInfo("151 Broome St", "New York", "NY", 10002) + NYCAddressInfo("151 Broome St", "New York", "NY", "10002") @patch("meshapi.validation.requests.get") def test_validate_address_good(self, mock_requests): @@ -49,13 +49,13 @@ def test_validate_address_good(self, mock_requests): mock_requests.side_effect = [mock_1, mock_2, mock_3] - nyc_addr_info = NYCAddressInfo("151 Broome St", "New York", "NY", 10002) + nyc_addr_info = NYCAddressInfo("151 Broome St", "New York", "NY", "10002") assert nyc_addr_info is not None assert nyc_addr_info.street_address == "151 Broome St" assert nyc_addr_info.city == "New York" assert nyc_addr_info.state == "NY" - assert nyc_addr_info.zip == 10002 + assert nyc_addr_info.zip == "10002" assert nyc_addr_info.longitude == -73.98492 assert nyc_addr_info.latitude == 40.716245 assert nyc_addr_info.altitude == 61.0 @@ -96,13 +96,13 @@ def test_validate_address_open_data_invalid_response(self, mock_requests): mock_requests.side_effect = [mock_1, mock_2, mock_test_case] - nyc_addr_info = NYCAddressInfo("151 Broome St", "New York", "NY", 10002) + nyc_addr_info = NYCAddressInfo("151 Broome St", "New York", "NY", "10002") assert nyc_addr_info is not None assert nyc_addr_info.street_address == "151 Broome St" assert nyc_addr_info.city == "New York" assert nyc_addr_info.state == "NY" - assert nyc_addr_info.zip == 10002 + assert nyc_addr_info.zip == "10002" assert nyc_addr_info.longitude == -73.98492 assert nyc_addr_info.latitude == 40.716245 assert nyc_addr_info.altitude is None diff --git a/src/meshapi/validation.py b/src/meshapi/validation.py index e79ace10..da78f817 100644 --- a/src/meshapi/validation.py +++ b/src/meshapi/validation.py @@ -96,7 +96,8 @@ def __init__(self, street_address: str, city: str, state: str, zip_code: str): # the closest matching street address it can find, so check that # the ZIP of what we entered matches what we got. - found_zip = nyc_planning_resp["features"][0]["properties"]["postalcode"] + # For some insane reason this is an integer, so we have to cast it to a string + found_zip = str(nyc_planning_resp["features"][0]["properties"]["postalcode"]) if found_zip != zip_code: raise AddressError( f"(NYC) Could not find address '{street_address}, {city}, {state} {zip_code}'. " @@ -110,7 +111,7 @@ def __init__(self, street_address: str, city: str, state: str, zip_code: str): self.city = addr_props["borough"].replace("Manhattan", "New York") self.state = addr_props["region_a"] - self.zip = addr_props["postalcode"] + self.zip = str(addr_props["postalcode"]) if ( not addr_props.get("addendum", {}).get("pad", {}).get("bin") diff --git a/test-results/.last-run.json b/test-results/.last-run.json new file mode 100644 index 00000000..5fca3f84 --- /dev/null +++ b/test-results/.last-run.json @@ -0,0 +1,4 @@ +{ + "status": "failed", + "failedTests": [] +} \ No newline at end of file