Commit 6d130af4 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Ensure iteration on XSMapping yield elements according to order in the XSD

elements should be treaten FIFO.
parent c29eea525d9e
...@@ -130,6 +130,48 @@ class XSIterateTC(unittest.TestCase): ...@@ -130,6 +130,48 @@ class XSIterateTC(unittest.TestCase):
])) ]))
self.assertRaises(StopIteration, next, element_defs) self.assertRaises(StopIteration, next, element_defs)
def test_rule(self):
element_defs = iter(XSDMMapping('AppraisalRule'))
edef = next(element_defs)
self.assertEqual(
readable_edef(edef),
('AppraisalRule', 'SEDAAppraisalRule', [
('Sequence',
[('seda_seq_appraisal_rule_rule', 'subject', 'SEDASeqAppraisalRuleRule')]),
('Alternative',
[('seda_alt_appraisal_rule_prevent_inheritance',
'subject',
'SEDAAltAppraisalRulePreventInheritance')]),
('FinalAction', [('seda_final_action', 'subject', 'Concept')]),
]))
edef = next(element_defs)
self.assertEqual(
readable_edef(edef),
('Sequence', 'SEDASeqAppraisalRuleRule', [
('Rule', [('seda_rule', 'subject', 'Concept')]),
('StartDate',
[('seda_start_date', 'object', 'SEDAStartDate'),
('start_date', 'subject', 'Date')])]))
edef = next(element_defs)
self.assertEqual(
readable_edef(edef),
('Alternative', 'SEDAAltAppraisalRulePreventInheritance', [
('PreventInheritance',
[('seda_prevent_inheritance', 'object', 'SEDAPreventInheritance'),
('prevent_inheritance', 'subject', 'Boolean')]),
('RefNonRuleId',
[('seda_ref_non_rule_id_from', 'object', 'SEDARefNonRuleId'),
('seda_ref_non_rule_id_to', 'subject', 'Concept')])]))
edef = next(element_defs)
self.assertEqual(
readable_edef(edef),
('StartDate', 'SEDAStartDate', []))
edef = next(element_defs)
self.assertEqual(
readable_edef(edef),
('PreventInheritance', 'SEDAPreventInheritance', []))
self.assertRaises(StopIteration, next, element_defs)
def test_binarydataobject(self): def test_binarydataobject(self):
element_defs = XSDMMapping('BinaryDataObject') element_defs = XSDMMapping('BinaryDataObject')
edef = next(iter(element_defs)) edef = next(iter(element_defs))
......
...@@ -414,7 +414,7 @@ def _xsiterate(xselement): # noqa ...@@ -414,7 +414,7 @@ def _xsiterate(xselement): # noqa
_push(xselement, etype_name(xselement)) _push(xselement, etype_name(xselement))
while _stack: while _stack:
parent, parent_etype, child_defs = _stack.pop() parent, parent_etype, child_defs = _stack.pop(0)
if child_defs is None: if child_defs is None:
child_defs = [] child_defs = []
skip = False skip = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment