Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Dec 17, 2024
1 parent 50bb0e6 commit 1bd93f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions package/tests/test_PartSeg/test_napari_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from PartSegCore.segmentation.noise_filtering import NoiseFilterSelection
from PartSegCore.segmentation.threshold import DoubleThresholdSelection, ThresholdSelection
from PartSegCore.segmentation.watershed import WatershedSelection
from PartSegCore.universal_const import LayerNamingFormat

NAPARI_GE_5_0 = parse_version(version("napari")) >= parse_version("0.5.0a1")
NAPARI_GE_4_19 = parse_version(version("napari")) >= parse_version("0.4.19a1")
Expand Down Expand Up @@ -655,3 +656,13 @@ def test_change_units(self, qtbot):
assert s.io_units == Units.nm
s.io_units = Units.mm
assert w.units_select.value == Units.mm

def test_change_layer_name_format(self, qtbot):
s = _settings.get_settings()
s.layer_naming_format = LayerNamingFormat.channel_only
w = _settings.SettingsEditor()
qtbot.addWidget(w.native)
w.layer_naming_select.value = LayerNamingFormat.channel_filename
assert s.layer_naming_format == LayerNamingFormat.channel_filename
s.layer_naming_format = LayerNamingFormat.channel_only
assert w.layer_naming_select.value == LayerNamingFormat.channel_only
14 changes: 14 additions & 0 deletions package/tests/test_PartSegCore/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from PartSegCore.segmentation.noise_filtering import DimensionType
from PartSegCore.segmentation.segmentation_algorithm import ThresholdAlgorithm
from PartSegCore.segmentation.threshold import RangeThresholdSelection
from PartSegCore.universal_const import LayerNamingFormat, format_layer_name
from PartSegCore.utils import ProfileDict, check_loaded_dict
from PartSegImage import Image

Expand Down Expand Up @@ -911,6 +912,19 @@ def test_load(self, tmp_path):
assert res.roi_info.roi.shape == (1, 1, 100, 100)


@pytest.mark.parametrize(
("value", "expected"),
[
(LayerNamingFormat.channel_only, "b"),
(LayerNamingFormat.filename_only, "a"),
(LayerNamingFormat.filename_channel, "a | b"),
(LayerNamingFormat.channel_filename, "b | a"),
],
)
def test_format_layer_name(value, expected):
assert format_layer_name(value, "a", "b") == expected


UPDATE_NAME_JSON = """
{"problematic set": {
"__MeasurementProfile__": true,
Expand Down

0 comments on commit 1bd93f7

Please sign in to comment.