def test_uscensus_reverse(): url = 'https://geocoding.geo.census.gov/geocoder/geographies/coordinates?x=-77.016389&y=38.904722&benchmark=4&vintage=4&format=json' data_file = 'tests/results/uscensus_reverse.json' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.get(url, text=input.read()) g = geocoder.uscensus((38.904722, -77.016389), method='reverse', timeout=10) assert g.ok
def test_uscensus(): url = 'https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address=595+Market+St+San+Francisco+CA+94105&benchmark=4&format=json' data_file = 'tests/results/uscensus.json' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.get(url, text=input.read()) g = geocoder.uscensus(' '.join([us_address, us_city, us_state, us_zipcode]), timeout=10) assert g.ok
def test_uscensus_reverse(): url = 'https://geocoding.geo.census.gov/geocoder/geographies/coordinates?x=-77.016389&y=38.904722&benchmark=4&vintage=4&format=json' data_file = 'tests/results/uscensus_reverse.json' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.get(url, text=input.read()) g = geocoder.uscensus((38.904722, -77.016389), method='reverse', timeout=10) assert g.ok
def test_uscensus(): url = 'https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address=595+Market+St+San+Francisco+CA+94105&benchmark=4&format=json' data_file = 'tests/results/uscensus.json' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.get(url, text=input.read()) g = geocoder.uscensus(' '.join( [us_address, us_city, us_state, us_zipcode]), timeout=10) assert g.ok
def test_uscensus_reverse(): url = 'https://geocoding.geo.census.gov/geocoder/locations/addressbatch' data_file = 'tests/results/uscensus_batch.csv' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.post(url, text=input.read()) g = geocoder.uscensus(us_locations, benchmark=9, method='batch') assert g.ok expected_results = [[38.846638, -76.92681], [41.30435, -72.89422]] assert [result.latlng for result in g] == expected_results
def test_uscensus_reverse(): url = 'https://geocoding.geo.census.gov/geocoder/locations/addressbatch' data_file = 'tests/results/uscensus_batch.csv' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.post(url, text=input.read()) g = geocoder.uscensus(us_locations, benchmark=9, method='batch') assert g.ok expected_results = [ [38.846638, -76.92681], [41.30435, -72.89422] ] assert [result.latlng for result in g] == expected_results
def test_uscensus_reverse(): g = geocoder.uscensus((38.904722, -77.016389), method='reverse') assert g.ok
def test_uscensus(): g = geocoder.uscensus(' '.join([us_address, us_city, us_state, us_zipcode])) assert g.ok assert g.city == us_city.upper()
def get_state_county(x): # apply reverse geocode to geocoordinates, but sleep a millisecond in between requests g = geocoder.uscensus(x, method='reverse') return g.state, g.county
def test_uscensus_reverse(): g = geocoder.uscensus((38.904722, -77.016389), method='reverse', timeout=10) assert g.ok