-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use devtools dfn utils, convert to toml before codegen, remove dfn at…
…tr from generated classes
- Loading branch information
Showing
10 changed files
with
65 additions
and
732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
import pytest | ||
from modflow_devtools.dfn import get_dfns | ||
from modflow_devtools.dfn2toml import convert | ||
|
||
from autotest.conftest import get_project_root_path | ||
from flopy.mf6.utils.codegen import make_all | ||
from flopy.mf6.utils.codegen.dfn import Dfn | ||
|
||
PROJ_ROOT = get_project_root_path() | ||
MF6_PATH = PROJ_ROOT / "flopy" / "mf6" | ||
DFN_PATH = MF6_PATH / "data" / "dfn" | ||
DFN_NAMES = [ | ||
dfn.stem for dfn in DFN_PATH.glob("*.dfn") if dfn.stem not in ["common", "flopy"] | ||
] | ||
DFN_PATH = PROJ_ROOT / "autotest" / "temp" / "dfn" | ||
TOML_PATH = DFN_PATH / "toml" | ||
MF6_OWNER = "MODFLOW-USGS" | ||
MF6_REPO = "modflow6" | ||
MF6_REF = "develop" | ||
|
||
|
||
@pytest.mark.parametrize("dfn_name", DFN_NAMES) | ||
def test_dfn_load(dfn_name): | ||
with ( | ||
open(DFN_PATH / "common.dfn", "r") as common_file, | ||
open(DFN_PATH / f"{dfn_name}.dfn", "r") as dfn_file, | ||
): | ||
name = Dfn.Name.parse(dfn_name) | ||
common, _ = Dfn._load_v1_flat(common_file) | ||
Dfn.load(dfn_file, name=name, common=common) | ||
def pytest_generate_tests(metafunc): | ||
if not any(DFN_PATH.glob("*.dfn")): | ||
get_dfns(MF6_OWNER, MF6_REPO, MF6_REF, DFN_PATH, verbose=True) | ||
|
||
convert(DFN_PATH, TOML_PATH) | ||
dfns = list(DFN_PATH.glob("*.dfn")) | ||
assert all( | ||
(TOML_PATH / f"{dfn.stem}.toml").is_file() | ||
for dfn in dfns | ||
if "common" not in dfn.stem | ||
) | ||
|
||
def test_make_all(function_tmpdir): | ||
make_all(DFN_PATH, function_tmpdir, verbose=True) | ||
|
||
@pytest.mark.parametrize("version,dfn_path", [(1, DFN_PATH), (2, TOML_PATH)]) | ||
def test_make_all(function_tmpdir, version, dfn_path): | ||
make_all(dfn_path, function_tmpdir, verbose=True, version=version) | ||
assert any(function_tmpdir.glob("*.py")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.