@@ -3334,6 +3334,33 @@ def test_write_geojson_rfc7946_coordinates(tmp_path, use_arrow):
33343334 assert np .array_equal (gdf_in_appended .geometry .values , points + points_append )
33353335
33363336
3337+ @pytest .mark .requires_arrow_write_api
3338+ def test_write_openfilegdb_overwrite_corrupt (tmp_path , use_arrow ):
3339+ """Test to overwriting an existing corrupt OpenFileGDB.
3340+
3341+ Test added in context of https://github.com/geopandas/pyogrio/issues/598
3342+ """
3343+ # Create a corrupt OpenFileGDB file. An empty directory suffices.
3344+ test_path = tmp_path / "test.gdb"
3345+ test_path .mkdir ()
3346+
3347+ # Overwrite the corrupt OpenFileGDB
3348+ gdf = gp .GeoDataFrame (
3349+ {"id" : [1.0 , 2.0 , 3.0 ]},
3350+ geometry = [shapely .Point (x , x ) for x in range (3 )],
3351+ crs = "EPSG:4326" ,
3352+ )
3353+ write_dataframe (
3354+ gdf , test_path , layer = "test_layer" , driver = "OpenFileGDB" , use_arrow = use_arrow
3355+ )
3356+
3357+ # Read back and verify it was (over)written correctly
3358+ assert test_path .exists ()
3359+ assert test_path .is_dir ()
3360+ read_gdf = read_dataframe (test_path , use_arrow = use_arrow )
3361+ assert_geodataframe_equal (gdf , read_gdf )
3362+
3363+
33373364@pytest .mark .requires_arrow_write_api
33383365@pytest .mark .skipif (
33393366 not GDAL_HAS_PARQUET_DRIVER , reason = "Parquet driver is not available"
0 commit comments