Skip to content

Commit

Permalink
add initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Oct 6, 2023
1 parent d721712 commit 6a19ee9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hydamo/hydamo/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def to_geopackage(self, file_path, use_schema=True):
None.
"""

file_path = Path(file_path)
for layer in self.layers:
gdf = getattr(self, layer).copy()
if not gdf.empty:
Expand Down Expand Up @@ -464,8 +464,8 @@ def to_geopackage(self, file_path, use_schema=True):
if gdf.index.name in gdf.columns:
gdf = gdf.reset_index(drop=True).copy()
gdf.to_file(file_path, layer=layer, driver="GPKG")

add_styles_to_geopackage(file_path)
if file_path.is_file():
add_styles_to_geopackage(file_path)

@classmethod
def from_geopackage(cls, file_path, check_columns=True, check_geotype=True):
Expand Down
17 changes: 17 additions & 0 deletions src/hydamo/tests/test_datamodel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path

import hydamo


def test_initialize():
damo = hydamo.HyDAMO()
assert damo.version == "2.2"
assert "stuw" in damo.layers
assert isinstance(damo.stuw, hydamo.ExtendedGeoDataFrame)
assert "kruinbreedte" in damo.stuw.columns
# no data is loaded
assert len(damo.stuw) == 0
# no file is written
path = Path("hydamo.gpkg")
damo.to_geopackage(path)
assert not path.is_file()

0 comments on commit 6a19ee9

Please sign in to comment.