def test_counties():
    counties = []
    states = []

    for state in geodata.geocode_states("us-48").get_geocodes()['found name']:
        for county in geodata.geocode_counties().states(state).scope('usa').get_geocodes()['found name']:
            states.append(state)
            counties.append(county)

    geocoded_counties = geodata.geocode_counties(counties).states(states).scope('usa').get_boundaries('country')

    assert_row(geocoded_counties, names=counties)
def test_select_all_query_with_empty_result_should_return_empty_dataframe():
    geocoder = geodata.geocode_counties().scope('Norway')

    geocodes = geocoder.get_geocodes()
    assert 0 == len(geocodes)

    centroids = geocoder.get_centroids()
    assert 0 == len(centroids)
def test_where_scope_with_existing_country_in_df():
    df = {
        'city': ['moscow', 'tashkent', 'washington'],
        'country': ['russia', 'uzbekistan', 'usa']
    }

    washington_county=geodata.geocode_counties('Washington county').states('iowa').countries('usa')
    cities = geodata.geocode_cities(df['city']).countries(df['country'])\
        .where('washington', country='usa', scope=washington_county)

    assert_row(cities.get_geocodes(), index=2, names='washington', country='usa', found_name='Washington')
def test_drop_not_found_with_namesakes():
    states = geodata.geocode_counties(['jefferson', 'trololo', 'jefferson']) \
        .states(['alabama', 'asd', 'arkansas']) \
        .countries(['usa', 'usa', 'usa']) \
        .ignore_not_found()

    assert_row(states.get_geocodes(),
               names=['jefferson', 'jefferson'],
               found_name=['Jefferson County', 'Jefferson County'],
               state=['alabama', 'arkansas'],
               country=['usa', 'usa']
               )
示例#5
0
def test_empty_request_centroid():
    orange_county = geodata.geocode_counties('orange county').scope(
        'north carolina')
    r = geodata.geocode_cities().scope(orange_county)
    df = r.get_centroids()
    assert_request_and_found_name_are_equal(df)
def test_where_with_parent():
    washington_county=geodata.geocode_counties('Washington county').states('Vermont').countries('usa')
    geodata.geocode_cities(['worcester', 'worcester']) \
        .countries(['usa', 'Great Britain']) \
        .where('worcester', country='usa', scope=washington_county) \
        .get_geocodes()
def test_fetch_all_counties_by_state():
    geodata.geocode_counties().states('New York').get_geocodes()
def test_where_scope_with_existing_country():
    washington_county=geodata.geocode_counties('Washington county').states('iowa').countries('usa')
    washington = geodata.geocode_cities('washington').countries('United States of America')\
        .where('washington', country='United States of America', scope=washington_county)

    assert_row(washington.get_geocodes(), names='washington', country='United States of America', found_name='Washington')