Skip to content

Commit 31f1aab

Browse files
committed
[version_converter] Automatically Add UUIDs For Sections
Adding UUIDs, when converting from odML version 1.0 to 1.1. If an ID already exists, it stays the same, if it is compatible with the python uuid types. Otherwise (also if empty) a new ID is created for the section.
1 parent 8565480 commit 31f1aab

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

odml/tools/version_converter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ def _check_add_ids(self, tree):
423423
"""
424424
root = tree.getroot()
425425
for sec in root.iter("section"):
426+
self._add_id(sec)
426427
for prop in sec.iter("property"):
427428
self._add_id(prop)
428429

test/test_version_converter.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def test_convert_odml_file_section(self):
276276
self.assertEqual(len(sec), 2)
277277

278278
# Test valid section tags.
279-
self.assertEqual(len(sec[0]), 10)
279+
self.assertEqual(len(sec[0]), 11)
280280
self.assertEqual(sec[0].find("name").text, "Section name")
281281
self.assertEqual(sec[0].find("type").text, "Section type")
282282
self.assertEqual(sec[0].find("definition").text, "Section definition")
@@ -286,10 +286,11 @@ def test_convert_odml_file_section(self):
286286
self.assertEqual(sec[0].find("include").text, "Section include")
287287
self.assertEqual(len(sec[0].findall("property")), 2)
288288
self.assertEqual(len(sec[0].findall("section")), 1)
289+
self.assertEqual(len(sec[0].findall("id")), 1)
289290

290291
# Test valid subsection tags.
291292
subsec = sec[0].find("section")
292-
self.assertEqual(len(subsec), 8)
293+
self.assertEqual(len(subsec), 9)
293294
self.assertEqual(subsec.find("name").text, "SubSection name")
294295
self.assertEqual(subsec.find("type").text, "SubSection type")
295296
self.assertEqual(subsec.find("definition").text, "SubSection definition")
@@ -298,10 +299,12 @@ def test_convert_odml_file_section(self):
298299
self.assertEqual(subsec.find("repository").text, local_url)
299300
self.assertEqual(subsec.find("include").text, "SubSection include")
300301
self.assertEqual(len(subsec.findall("property")), 1)
302+
self.assertEqual(len(subsec.findall("id")), 1)
301303

302304
# Test absence of non-Section tags
303-
self.assertEqual(len(sec[1]), 1)
305+
self.assertEqual(len(sec[1]), 2)
304306
self.assertEqual(len(sec[1].findall("name")), 1)
307+
self.assertEqual(len(sec[1].findall("id")), 1)
305308

306309
# Test presence of v1.0 repository tag and warning log entry
307310
doc = """
@@ -539,7 +542,8 @@ def test_convert_odml_file_value(self):
539542
conv_doc = vc._convert(vc._parse_xml())
540543
root = conv_doc.getroot()
541544
sec = root.find("section")
542-
self.assertEqual(len(sec), 17)
545+
self.assertEqual(len(sec), 18)
546+
self.assertEqual(len(sec.findall("id")), 1)
543547

544548
# Test single value export
545549
prop = sec.findall("property")[0]

0 commit comments

Comments
 (0)