Skip to content

Commit 1231d2f

Browse files
committed
[test-section] Add Test for Leaf-Export
1 parent 77df9c4 commit 1231d2f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/test_section.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,41 @@ def test_create_property(self):
943943
prop = root.create_property(name, dtype=dtype)
944944
self.assertIsNone(prop.dtype)
945945

946+
def test_export_leaf(self):
947+
doc = Document()
948+
first = doc.create_section("first")
949+
second = first.create_section("second")
950+
third = first.create_section("third")
951+
952+
name = "prop1"
953+
values = [1.3]
954+
first.create_property(name, value=values)
955+
956+
name = "prop2"
957+
values = ["words"]
958+
first.create_property(name, value=values)
959+
960+
name = "prop3"
961+
values = ["a", "b"]
962+
second.create_property(name, value=values)
963+
964+
ex1 = first.export_leaf()
965+
self.assertEqual(len(ex1.sections), 1)
966+
self.assertEqual(len(ex1['first'].properties), 2)
967+
self.assertEqual(len(ex1['first'].sections), 0)
968+
969+
ex2 = second.export_leaf()
970+
self.assertEqual(len(ex2.sections), 1)
971+
self.assertEqual(len(ex2['first'].properties), 0)
972+
self.assertEqual(len(ex2['first'].sections), 1)
973+
self.assertEqual(len(ex2['first']['second'].properties), 1)
974+
975+
ex3 = third.export_leaf()
976+
self.assertEqual(len(ex3.sections), 1)
977+
self.assertEqual(len(ex3['first'].properties), 0)
978+
self.assertEqual(len(ex3['first'].sections), 1)
979+
self.assertEqual(len(ex3['first']['third']), 0)
980+
946981
def test_link(self):
947982
pass
948983

0 commit comments

Comments
 (0)