def test_regions(mock_geocoding): try: regions(level=LEVEL, request=FILTER_LIST, within=REGION_NAME).to_data_frame() except Exception: pass # response doesn't contain proper feature with ids - ignore mock_geocoding.assert_called_with( GeocodingRequest(requested_payload=[], resolution=None, region_queries=[REGION_QUERY_LA, REGION_QUERY_NY], level=LEVEL_KIND, namesake_example_limit=NAMESAKES_EXAMPLE_LIMIT))
def test_resolution(): r = geodata.regions(request=[ 'monaco', ], level='country') sizes = [] for res in range(1, 16): b = r.boundaries(res) sizes.append(len(b['request'])) assert 15 == len(sizes)
def test_duplications_in_filter_should_preserve_order(): df = geodata.regions(request=['Texas', 'TX', 'Arizona', 'Texas'], level='state').to_data_frame() assert ['Texas', 'TX', 'Arizona', 'Texas'] == df['request'].tolist()
def test_order(): bound = geodata.regions(request=['Russia', 'USA', 'France', 'Japan']) df = bound.to_data_frame() assert ['Russia', 'USA', 'France', 'Japan'] == df['request'].tolist()
def test_ambiguous_not_found_with_level(): with pytest.raises(ValueError) as exception: r = geodata.regions(request=['zimbabwe', 'moscow'], level='country') assert 'No objects were found for moscow.\n' == exception.value.args[0]
def test_regions(): map_regions = geodata.regions(level='country', request=['Russia', 'USA']) map_regions.boundaries() assert map_regions is not None
def test_multipolygon_boundaries_request(): assert geodata.regions(request='USA').boundaries(1) is not None
def test_polygon_boundaries_request(): print(geodata.regions(request='colorado').boundaries(14))
def test_centroids_request(): print(geodata.regions(request='texas').centroids())
def test_limits_request(): print(geodata.regions(request='texas').limits())
def test_duplications(): r1 = geodata.regions(request=['Virginia', 'West Virginia'], within='USA') r1.centroids()
def test_address_request(address, level, region, expected_name): r = geodata.regions(request=address, level=level, within=region) assert_row(r.to_data_frame(), found_name=expected_name)