44from imcflibs .pathtools import parse_path
55from imcflibs .pathtools import jython_fiji_exists
66from imcflibs .pathtools import image_basename
7+ from imcflibs .pathtools import gen_name_from_orig
8+ from imcflibs .pathtools import derive_out_dir
79
810
911def test_parse_path ():
@@ -30,6 +32,19 @@ def test_parse_path():
3032 assert path_to_dir ["ext" ] == ""
3133
3234
35+ def test_parse_path_with_prefix ():
36+ """Test parse_path with a prefix parameter."""
37+ exp_full = "/FOO/BAR/tmp/foo/file.suffix"
38+ prefix = "/FOO/BAR/"
39+ path = "/tmp/foo/file.suffix"
40+ assert parse_path (path , prefix )["full" ] == exp_full
41+
42+ # test again without trailing / leading slashes:
43+ prefix = "/FOO/BAR"
44+ path = "tmp/foo/file.suffix"
45+ assert parse_path (path , prefix )["full" ] == exp_full
46+
47+
3348def test_parse_path_windows ():
3449 """Test using a Windows-style path."""
3550 path = r"C:\Foo\Bar"
@@ -81,3 +96,21 @@ def test_image_basename():
8196 assert image_basename ("/path/to/image_file_01.png" ) == "image_file_01"
8297 assert image_basename ("more-complex-stack.ome.tif" ) == "more-complex-stack"
8398 assert image_basename ("/tmp/FoObAr.OMe.tIf" ) == "FoObAr"
99+
100+
101+ def test_gen_name_from_orig ():
102+ """Test assembling an output name from input, tag and suffix."""
103+ outpath = "/outpath"
104+ inpath = "/inpath/to/foobar.tif"
105+ tag = "-avg"
106+ suffix = ".h5"
107+ generated = gen_name_from_orig (outpath , inpath , tag , suffix )
108+ assert generated == "/outpath/foobar-avg.h5"
109+
110+
111+ def test_derive_out_dir ():
112+ """Test derive_out_dir() using various parameter combinations."""
113+ assert derive_out_dir ("/foo" , "-" ) == "/foo"
114+ assert derive_out_dir ("/foo" , "none" ) == "/foo"
115+ assert derive_out_dir ("/foo" , "NONE" ) == "/foo"
116+ assert derive_out_dir ("/foo" , "/bar" ) == "/bar"
0 commit comments