Commit 6abe1b33 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 #89644 failed with stages
in 2 minutes and 37 seconds
......@@ -757,11 +757,13 @@ class SEDA22RelaxNGExport(SEDA2RelaxNGExport):
if nodes or opt_nodes:
# insert after definition of dop's id attribute
for node in chain(nodes, opt_nodes):
zeroormore = self.element("rng:zeroOrMore")
choice = self.element("rng:choice", zeroormore)
dop[0].addnext(zeroormore)
# insert DataObjectGroup
group = self.element(
"rng:element", attributes={"name": "DataObjectGroup"}
"rng:element", choice, attributes={"name": "DataObjectGroup"}
)
dop[0].addnext(group)
group.append(node)
......
......@@ -534,7 +534,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
profile = self.profile_etree(transfer)
dop = self.get_element(profile, "DataObjectPackage")
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
# and BinaryDataObject nodes
......@@ -542,7 +542,7 @@ class SEDA2RNGExportTC(RelaxNGTestMixin, CubicWebTC):
profile = self.profile_etree(transfer)
dop = self.get_element(profile, "DataObjectPackage")
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):
......
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