Skip to content

Commit 121175d

Browse files
authored
Fix __parse_volume (#586)
* test: Added test for volume dumping/ parsing * bugfix: Incorrect parameter name
1 parent d029db4 commit 121175d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

webknossos/tests/test_skeleton.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,22 @@ def test_import_export_round_trip(tmp_path: Path) -> None:
224224

225225
nml.save(export_path)
226226
diff_files(snapshot_path, export_path)
227+
228+
def test_volume_dump_round_trip(tmp_path: Path) -> None:
229+
from webknossos.skeleton.nml import Volume, __dump_volume, __parse_volume
230+
from loxun import XmlWriter
231+
import xml.etree.ElementTree as ET
232+
233+
export_path = tmp_path / "volume_dump.xml"
234+
volume_in = Volume(id=0, location="data_Volume.zip", fallback_layer="my_very_important_layer")
235+
volume_out = None
236+
237+
with open(export_path, 'wb') as f:
238+
with XmlWriter(f) as xf:
239+
__dump_volume(xf, volume_in)
240+
241+
with open(export_path, 'rb') as f:
242+
tree = ET.parse(export_path)
243+
volume_out = __parse_volume(next(tree.iter()))
244+
245+
assert volume_in == volume_out

webknossos/webknossos/skeleton/nml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def __parse_volume(nml_volume: Element) -> Volume:
382382
return Volume(
383383
int(enforce_not_null(nml_volume.get("id"))),
384384
enforce_not_null(nml_volume.get("location")),
385-
nml_volume.get("fallback_layer", default=None),
385+
nml_volume.get("fallbackLayer", default=None),
386386
)
387387

388388

0 commit comments

Comments
 (0)