def convert_national_to_nyc_addr_if_needed(self, info: OnboardingInfo) -> bool: if not (info.geocoded_address and info.non_nyc_city and info.state == US_STATE_CHOICES.NY): return False info.update_geocoded_point_from_geometry() county = info.lookup_county() assert county, f"geocoded NYC address '{info.geocoded_address}' should have a county!" if county in NYC_COUNTY_BOROUGHS: self.log( f"National address at '{info.geocoded_address}' appears to be in NYC." ) info.borough = NYC_COUNTY_BOROUGHS[county] info.non_nyc_city = "" info.geocoded_address = "" assert info.maybe_lookup_new_addr_metadata() return True return False
def test_it_returns_county_when_county_matches(self, db): CountyFactory() oi = OnboardingInfo(state="NY", geocoded_point=Point(0.1, 0.1)) assert oi.lookup_county() == "Funkypants"
def test_it_returns_none_when_no_county_matches(self, db): CountyFactory() oi = OnboardingInfo(state="NY", geocoded_point=Point(50, 50)) assert oi.lookup_county() is None