Commit 1652ae0c authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

feat: schema validation, add choice + zeroOrMore for DataObjectGroup (closes #35)

--HG--
branch : seda21
parent da9c60e6a4c7
Pipeline #89642 failed with stages
in 1 minute and 18 seconds
...@@ -757,11 +757,13 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport): ...@@ -757,11 +757,13 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport):
if nodes or opt_nodes: if nodes or opt_nodes:
# insert after definition of dop's id attribute # insert after definition of dop's id attribute
for node in chain(nodes, opt_nodes): for node in chain(nodes, opt_nodes):
zeroormore = self.element("rng:zeroOrMore")
choice = self.element("rng:choice", zeroormore)
dop[0].addnext(zeroormore)
# insert DataObjectGroup # insert DataObjectGroup
group = self.element( group = self.element(
"rng:element", attributes={"name": "DataObjectGroup"} "rng:element", choice, attributes={"name": "DataObjectGroup"}
) )
dop[0].addnext(group)
group.append(node) group.append(node)
......
...@@ -534,7 +534,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC): ...@@ -534,7 +534,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
profile = self.profile_etree(transfer) profile = self.profile_etree(transfer)
dop = self.get_element(profile, "DataObjectPackage") dop = self.get_element(profile, "DataObjectPackage")
self.assertEqual( self.assertEqual(
len(self.xpath(dop, './rng:element[@name="DataObjectGroup"]/*')), 3 len(self.xpath(dop, './rng:zeroOrMore/rng:choice/rng:element[@name="DataObjectGroup"]/*')), 3
) )
# setting some cardinality to 1 will remove rng:optional parent of the DataObjectPackage # setting some cardinality to 1 will remove rng:optional parent of the DataObjectPackage
# and BinaryDataObject nodes # and BinaryDataObject nodes
...@@ -542,7 +542,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC): ...@@ -542,7 +542,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
profile = self.profile_etree(transfer) profile = self.profile_etree(transfer)
dop = self.get_element(profile, "DataObjectPackage") dop = self.get_element(profile, "DataObjectPackage")
self.assertEqual( self.assertEqual(
len(self.xpath(dop, './rng:element[@name="DataObjectGroup"]/*')), 3 len(self.xpath(dop, './rng:zeroOrMore/rng:choice/rng:element[@name="DataObjectGroup"]/*')), 3
) )
def test_transfer_annotation(self): def test_transfer_annotation(self):
......
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