Skip to content

Commit

Permalink
reformat the TestExtModel
Browse files Browse the repository at this point in the history
  • Loading branch information
MAfarrag committed Nov 17, 2024
1 parent a3b335b commit 1a17cd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def meteo_interpolation_methods() -> List[str]:
return ["nearestNb", "linearSpaceTime", "Possible values: nearestNb (only with station data in forcingFileType=netcdf ). "]


@pytest.fixture
def input_files_dir() -> Path:
return Path("tests/data/input")

@pytest.fixture
def time_series_file() -> Path:
return Path("tests/data/inputs/tim/single_data_for_timeseries.tim")
Expand All @@ -43,3 +47,4 @@ def time_series_file() -> Path:
@pytest.fixture
def boundary_condition_file() -> Path:
return Path("tests/data/inputs/dflowfm_individual_files/FlowFM_boundaryconditions2d_and_vectors.bc")

24 changes: 6 additions & 18 deletions tests/dflowfm/test_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,8 @@ class TestExtModel:
"""Class to test all methods contained in the
hydrolib.core.dflowfm.ext.models.ExtModel class"""

def test_construct_from_file_with_tim(self):
input_ext = (
test_input_dir
/ "e02/f006_external_forcing/c063_rain_tim/rainschematic.ext"
)
def test_construct_from_file_with_tim(self, input_files_dir: Path):
input_ext = input_files_dir.joinpath("e02/f006_external_forcing/c063_rain_tim/rainschematic.ext")

ext_model = ExtModel(input_ext)

Expand All @@ -619,12 +616,8 @@ def test_construct_from_file_with_tim(self):

assert len(ext_model.meteo[0].forcingfile.timeseries) == 14

def test_construct_from_file_with_bc(self):
input_ext = (
test_input_dir
/ "e02/f006_external_forcing/c069_rain_bc/rainschematic.ext"
)

def test_construct_from_file_with_bc(self, input_files_dir: Path):
input_ext = input_files_dir.joinpath("e02/f006_external_forcing/c069_rain_bc/rainschematic.ext")
ext_model = ExtModel(input_ext)

assert isinstance(ext_model, ExtModel)
Expand All @@ -633,12 +626,8 @@ def test_construct_from_file_with_bc(self):
assert isinstance(ext_model.meteo[0].forcingfile, ForcingModel)
assert ext_model.meteo[0].forcingfiletype == MeteoForcingFileType.bcascii

def test_construct_from_file_with_netcdf(self):
input_ext = (
test_input_dir
/ "e02/f006_external_forcing/c067_rain_netcdf_stations/rainschematic.ext"
)

def test_construct_from_file_with_netcdf(self, input_files_dir: Path):
input_ext = input_files_dir.joinpath("e02/f006_external_forcing/c067_rain_netcdf_stations/rainschematic.ext")
ext_model = ExtModel(input_ext)

assert isinstance(ext_model, ExtModel)
Expand All @@ -647,7 +636,6 @@ def test_construct_from_file_with_netcdf(self):
assert isinstance(ext_model.meteo[0].forcingfile, DiskOnlyFileModel)
assert ext_model.meteo[0].forcingfiletype == MeteoForcingFileType.netcdf


def test_ext_model_correct_default_serializer_config(self):
model = ExtModel()

Expand Down

0 comments on commit 1a17cd2

Please sign in to comment.