Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Extra parameters parsing tests #417

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions tests/test_units/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import os
from pathlib import Path
from tempfile import NamedTemporaryFile

import pytest
import yaml
Expand Down Expand Up @@ -133,3 +134,69 @@ def test_invalid_dict(globalconfig2, drogon_summary, drogon_volumes):
print(exc_info)
exd.export(in_dict, name="invalid")
assert exc_info[1] == "Object of type Table is not JSON serializable"


def test_read_parameters_txt():
with NamedTemporaryFile() as tf:
tf.write(
b"""SENSNAME rms_seed
SENSCASE p10_p90
RMS_SEED 1000
KVKH_CHANNEL 0.6
KVKH_CREVASSE 0.3
GLOBVAR:VOLON_FLOODPLAIN_VOLFRAC 0.256355
GLOBVAR:VOLON_PERMH_CHANNEL 1100
GLOBVAR:VOLON_PORO_CHANNEL 0.2
LOG10_GLOBVAR:FAULT_SEAL_SCALING 0.685516
LOG10_MULTREGT:MULT_THERYS_VOLON -3.21365
LOG10_MULTREGT:MULT_VALYSAR_THERYS -3.2582
"""
)
tf.flush()
assert read_parameters_txt(tf.name) == {
"SENSNAME": "rms_seed",
"SENSCASE": "p10_p90",
"RMS_SEED": 1000,
"KVKH_CHANNEL": 0.6,
"KVKH_CREVASSE": 0.3,
"GLOBVAR:VOLON_FLOODPLAIN_VOLFRAC": 0.256355,
"GLOBVAR:VOLON_PERMH_CHANNEL": 1100,
"GLOBVAR:VOLON_PORO_CHANNEL": 0.2,
"LOG10_GLOBVAR:FAULT_SEAL_SCALING": 0.685516,
"LOG10_MULTREGT:MULT_THERYS_VOLON": -3.21365,
"LOG10_MULTREGT:MULT_VALYSAR_THERYS": -3.2582,
}


def test_nested_parameters_dict():
assert nested_parameters_dict(
{
"SENSNAME": "rms_seed",
"SENSCASE": "p10_p90",
"RMS_SEED": 1000,
"KVKH_CHANNEL": 0.6,
"KVKH_CREVASSE": 0.3,
"GLOBVAR:VOLON_FLOODPLAIN_VOLFRAC": 0.256355,
"GLOBVAR:VOLON_PERMH_CHANNEL": 1100,
"GLOBVAR:VOLON_PORO_CHANNEL": 0.2,
"LOG10_GLOBVAR:FAULT_SEAL_SCALING": 0.685516,
"LOG10_MULTREGT:MULT_THERYS_VOLON": -3.21365,
"LOG10_MULTREGT:MULT_VALYSAR_THERYS": -3.2582,
}
) == {
"SENSNAME": "rms_seed",
"SENSCASE": "p10_p90",
"RMS_SEED": 1000,
"KVKH_CHANNEL": 0.6,
"KVKH_CREVASSE": 0.3,
"GLOBVAR": {
"VOLON_FLOODPLAIN_VOLFRAC": 0.256355,
"VOLON_PERMH_CHANNEL": 1100,
"VOLON_PORO_CHANNEL": 0.2,
},
"LOG10_GLOBVAR": {"FAULT_SEAL_SCALING": 0.685516},
"LOG10_MULTREGT": {
"MULT_THERYS_VOLON": -3.21365,
"MULT_VALYSAR_THERYS": -3.2582,
},
}
Loading