Skip to content
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
44 changes: 44 additions & 0 deletions tests/test_gui_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import dataclasses

import pytest

from venting.gui.config import GuiCaseConfig
Expand Down Expand Up @@ -25,6 +27,48 @@ def test_gui_config_validation_rejects_bad_enum():
cfg.validate()


def test_read_cfg_topology_not_float_converted():
"""Regression: topology='two_chain_shared_vest' must not be passed to float().

Reproduces the bug where _read_cfg() raised:
ValueError: could not convert string to float: 'two_chain_shared_vest'
because 'topology' was missing from the string-exclusion set.
"""
# Simulate the kwargs dict that Qt widgets would produce (all values as str)
kwargs = {f.name: str(f.default) for f in dataclasses.fields(GuiCaseConfig)}
kwargs["topology"] = "two_chain_shared_vest"

int_fields = {
"N_chain",
"N_chain_b",
"N_par",
"n_int_per_interface",
"n_exit",
"n_pts",
}
string_fields = {
"int_model",
"exit_model",
"topology",
"external_model",
"profile_kind",
"profile_pressure_unit",
"thermo",
"wall_model",
"profile_file",
"output_case_name",
}
float_fields = set(kwargs) - int_fields - string_fields

# Must not raise ValueError
for k in int_fields:
int(kwargs[k])
for k in float_fields:
float(kwargs[k])

assert "topology" not in float_fields


def test_gui_config_validation_rejects_nonpositive():
cfg = GuiCaseConfig(V_cell_m3=0.0)
with pytest.raises(ValueError):
Expand Down