Skip to content

Commit

Permalink
fix: assert expected columns are present even on empty output
Browse files Browse the repository at this point in the history
  • Loading branch information
SlowMo24 committed Aug 1, 2024
1 parent 92e0e9c commit d3e77be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ohsome/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ def _as_geodataframe(
"""

if len(self.data["features"]) == 0:
return gpd.GeoDataFrame(crs="epsg:4326", columns=["@osmId", "geometry"])
return gpd.GeoDataFrame(
crs="epsg:4326",
columns=["@osmId", "geometry"]
+ (
list(explode_tags) + ["@other_tags"]
if explode_tags is not None
else []
),
)

try:
if explode_tags is not None:
Expand Down
2 changes: 1 addition & 1 deletion ohsome/test/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def test_empty_geodataframe(base_client):

assert isinstance(result, gpd.GeoDataFrame)
assert result.empty
assert result.columns == ["@osmId", "geometry", "@other_tags"]
assert result.columns.to_list() == ["@osmId", "geometry", "@other_tags"]


@pytest.mark.vcr
Expand Down

0 comments on commit d3e77be

Please sign in to comment.