@@ -520,6 +520,44 @@ def test_convert_odml_file_value(self):
520
520
self .assertEqual (len (prop ), 1 )
521
521
self .assertEqual (len (prop .findall ("name" )), 1 )
522
522
523
+ def test_parse_dict_sections (self ):
524
+ # Test appending tags; not appending empty subsections or properties
525
+ root = ET .Element ("root" )
526
+ sec_dict = [{'name' : 'sec_one' , 'sections' : [], 'properties' : []}]
527
+
528
+ self .assertEqual (len (root .getchildren ()), 0 )
529
+ self .VC ("" )._parse_dict_sections (root , sec_dict )
530
+ self .assertEqual (len (root .getchildren ()), 1 )
531
+ self .assertIsNotNone (root .find ("section" ).find ("name" ))
532
+
533
+ # Test appending multiple sections
534
+ root = ET .Element ("root" )
535
+ sec_dict = [{'name' : 'sec_one' }, {'name' : 'sec_two' }, {'name' : 'sec_three' }]
536
+
537
+ self .assertEqual (len (root .getchildren ()), 0 )
538
+ self .VC ("" )._parse_dict_sections (root , sec_dict )
539
+ self .assertEqual (len (root .getchildren ()), 3 )
540
+
541
+ # Test appending subsections
542
+ root = ET .Element ("root" )
543
+ sec_dict = [{'name' : 'sec_one' , 'sections' : [{'name' : 'sub_one' },
544
+ {'name' : 'sub_two' }]}]
545
+ self .assertEqual (len (root .getchildren ()), 0 )
546
+ self .VC ("" )._parse_dict_sections (root , sec_dict )
547
+ sec = root .find ("section" )
548
+ self .assertEqual (len (sec .getchildren ()), 3 )
549
+ self .assertEqual (len (sec .findall ("section" )), 2 )
550
+
551
+ # Test appending properties
552
+ root = ET .Element ("root" )
553
+ sec_dict = [{'name' : 'sec_one' , 'properties' : [{'name' : 'prop_one' },
554
+ {'name' : 'prop_two' }]}]
555
+ self .assertEqual (len (root .getchildren ()), 0 )
556
+ self .VC ("" )._parse_dict_sections (root , sec_dict )
557
+ sec = root .find ("section" )
558
+ self .assertEqual (len (sec .getchildren ()), 3 )
559
+ self .assertEqual (len (sec .findall ("property" )), 2 )
560
+
523
561
def test_parse_dict_properties (self ):
524
562
# Test appending tags and moving values
525
563
root = ET .Element ("root" )
0 commit comments