@@ -257,6 +257,48 @@ def test_prop_cardinality(self):
257257 self ._test_cardinality_load ("prop_cardinality" , yaml_doc , card_dict ,
258258 sec_empty , sec_max , sec_min , sec_full )
259259
260+ def test_sec_cardinality (self ):
261+ """
262+ Test saving and loading of Section sections cardinality variants to
263+ and from all supported file formats.
264+ """
265+ doc = odml .Document ()
266+
267+ sec_empty = "card_empty"
268+ sec_max = "card_max"
269+ sec_min = "card_min"
270+ sec_full = "card_full"
271+ card_dict = {
272+ sec_empty : None ,
273+ sec_max : (None , 10 ),
274+ sec_min : (2 , None ),
275+ sec_full : (1 , 5 )
276+ }
277+
278+ _ = odml .Section (name = sec_empty , type = "test" , parent = doc )
279+ _ = odml .Section (name = sec_max , sec_cardinality = card_dict [sec_max ], type = "test" , parent = doc )
280+ _ = odml .Section (name = sec_min , sec_cardinality = card_dict [sec_min ], type = "test" , parent = doc )
281+ _ = odml .Section (name = sec_full , sec_cardinality = card_dict [sec_full ],
282+ type = "test" , parent = doc )
283+
284+ # Test saving to and loading from an XML file
285+ odml .save (doc , self .xml_file )
286+ xml_doc = odml .load (self .xml_file )
287+ self ._test_cardinality_load ("sec_cardinality" , xml_doc , card_dict ,
288+ sec_empty , sec_max , sec_min , sec_full )
289+
290+ # Test saving to and loading from a JSON file
291+ odml .save (doc , self .json_file , "JSON" )
292+ json_doc = odml .load (self .json_file , "JSON" )
293+ self ._test_cardinality_load ("sec_cardinality" , json_doc , card_dict ,
294+ sec_empty , sec_max , sec_min , sec_full )
295+
296+ # Test saving to and loading from a YAML file
297+ odml .save (doc , self .yaml_file , "YAML" )
298+ yaml_doc = odml .load (self .yaml_file , "YAML" )
299+ self ._test_cardinality_load ("sec_cardinality" , yaml_doc , card_dict ,
300+ sec_empty , sec_max , sec_min , sec_full )
301+
260302 def test_link (self ):
261303 pass
262304
0 commit comments