Skip to content

Commit

Permalink
Move _gdf_matches_json_alt func to init
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevenray Janke committed Jun 17, 2024
1 parent 1856c71 commit 8ba815d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 6 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import h5py
from geopandas import GeoDataFrame

import json
import hashlib
from pathlib import Path

Expand All @@ -20,3 +20,8 @@ def _gdf_matches_json(gdf: GeoDataFrame, json_file: Path) -> bool:
def get_sha1_hash(path: Path) -> str:
with open(path, "rb") as f:
return hashlib.sha1(f.read()).hexdigest()


def _gdf_matches_json_alt(gdf: GeoDataFrame, json_file: Path) -> bool:
with open(json_file) as j:
return json.loads(gdf.to_json()) == json.load(j)
9 changes: 2 additions & 7 deletions tests/test_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from src.rashdf import RasGeomHdf

from . import _create_hdf_with_group_attrs, _gdf_matches_json
from . import _create_hdf_with_group_attrs, _gdf_matches_json, _gdf_matches_json_alt

TEST_DATA = Path("./tests/data")
MUNCIE_G05 = TEST_DATA / "ras/Muncie.g05.hdf"
Expand All @@ -29,11 +29,6 @@ def test_projection(tmp_path):
assert ras_hdf.projection() == CRS.from_wkt(wkt)


def _gdf_matches_json_alt(gdf: GeoDataFrame, json_file: Path) -> bool:
with open(json_file) as j:
return json.loads(gdf.to_json()) == json.load(j)


def test_mesh_area_names():
with RasGeomHdf(MUNCIE_G05) as ghdf:
assert ghdf.mesh_area_names() == ["2D Interior Area", "Perimeter_NW"]
Expand Down Expand Up @@ -206,6 +201,6 @@ def test_cross_sections_velocity():
assert _gdf_matches_json_alt(ghdf.cross_sections_velocity(), xs_velocity_json)


def ttest_cross_sections_velocity_not_found():
def test_cross_sections_velocity_not_found():
with RasGeomHdf(COAL_G01) as ghdf:
assert (ghdf.cross_sections_velocity(), None)

0 comments on commit 8ba815d

Please sign in to comment.