Files
TJWaterServerBinary/tests/unit/test_wndb_options.py
jiang 90b02057bc
Generic Container CI/CD / test-build-publish (push) Successful in 1m13s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 1m13s
feat(projects): automate project infrastructure provisioning
2026-09-11 10:57:51 +08:00

39 lines
1.3 KiB
Python

from app.native.wndb.model.options_v3 import _inp_in_option_v3, inp_in_option_v3
def _operation_by_type(section: list[str], option_type: str) -> dict[str, str]:
result = _inp_in_option_v3(section)
return next(operation for operation in result.operations if operation["type"] == option_type)
def test_v3_import_preserves_legacy_options_from_standard_inp() -> None:
section = [
"Units LPS",
"Pattern PAT_BASE",
"Quality None mg/L",
"Trials 80",
"Unbalanced Continue 10",
"CHECKFREQ 2",
]
legacy = _operation_by_type(section, "option")
v3 = _operation_by_type(section, "option_v3")
assert legacy["PATTERN"] == "PAT_BASE"
assert legacy["QUALITY"] == "None mg/L"
assert legacy["TRIALS"] == "80"
assert legacy["UNBALANCED"] == "CONTINUE 10"
assert legacy["CHECKFREQ"] == "2"
assert v3["DEMAND_PATTERN"] == "PAT_BASE"
assert v3["QUALITY_MODEL"] == "NONE"
statement = inp_in_option_v3(section)
assert "engine_version = 'legacy' and key = 'PATTERN'" in statement
assert "engine_version = 'v3' and key = 'DEMAND_PATTERN'" in statement
def test_v3_import_ignores_empty_option_lines() -> None:
legacy = _operation_by_type(["", " ", "Pattern PAT_BASE"], "option")
assert legacy["PATTERN"] == "PAT_BASE"