|
| 1 | +import pytest |
| 2 | + |
| 3 | +from modflow_devtools.programs import get_program, get_programs, load_programs |
| 4 | + |
| 5 | + |
| 6 | +def test_load_programs(): |
| 7 | + programs = get_programs() |
| 8 | + assert isinstance(programs, dict) |
| 9 | + assert "mf6" in programs |
| 10 | + mf6 = get_program("mf6") |
| 11 | + assert mf6 == programs["mf6"] |
| 12 | + assert isinstance(mf6.version, str) |
| 13 | + assert isinstance(mf6.current, bool) |
| 14 | + assert isinstance(mf6.url, str) |
| 15 | + assert isinstance(mf6.dirname, str) |
| 16 | + assert isinstance(mf6.srcdir, str) |
| 17 | + assert isinstance(mf6.standard_switch, bool) |
| 18 | + assert isinstance(mf6.double_switch, bool) |
| 19 | + assert isinstance(mf6.shared_object, bool) |
| 20 | + |
| 21 | + |
| 22 | +def test_strict_unrecognized_keys(function_tmpdir): |
| 23 | + tmp_path = function_tmpdir / "programs.csv" |
| 24 | + with tmp_path.open("w") as f: |
| 25 | + f.write( |
| 26 | + "target,version,current,url,dirname,srcdir,standard_switch,double_switch,shared_object,garbage\n" |
| 27 | + ) |
| 28 | + f.write( |
| 29 | + "mf6,6.6.3,True,https://github.com/MODFLOW-ORG/modflow6/releases/download/6.6.3/mf6.6.3_linux.zip,mf6.6.3_linux,src,True,False,False,garbage\n" |
| 30 | + ) |
| 31 | + |
| 32 | + with pytest.raises(ValueError) as e: |
| 33 | + load_programs(tmp_path, strict=True) |
| 34 | + assert "Unrecognized keys in program data: {'unrecognized_key'}" in e.message |
0 commit comments