Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7342974
D7244.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D7244.id.diff
View Options
diff --git a/swh/deposit/tests/api/test_checks.py b/swh/deposit/tests/api/test_checks.py
--- a/swh/deposit/tests/api/test_checks.py
+++ b/swh/deposit/tests/api/test_checks.py
@@ -367,6 +367,84 @@
"fields": ["swh:deposit"],
},
),
+ (
+ f"""\
+ <entry {XMLNS}>
+ <url>something</url>
+ <external_identifier>something-else</external_identifier>
+ <title>bar</title>
+ <author>someone</author>
+ <swh:deposit>
+ <swh:add_to_origin>
+ <swh:origin url="http://example.org" />
+ </swh:add_to_origin>
+ <swh:create_origin>
+ <swh:origin url="http://example.org" />
+ </swh:create_origin>
+ </swh:deposit>
+ </entry>
+ """,
+ {
+ "summary": (
+ r".*Reason: assertion test if false.*"
+ r"Schema:\n*"
+ r' *<xsd:assert[^>]+ id="swhdeposit-incompatible-create-and-add".*'
+ ),
+ "fields": ["swh:deposit"],
+ },
+ ),
+ (
+ f"""\
+ <entry {XMLNS}>
+ <url>something</url>
+ <external_identifier>something-else</external_identifier>
+ <title>bar</title>
+ <author>someone</author>
+ <swh:deposit>
+ <swh:create_origin>
+ <swh:origin url="http://example.org" />
+ </swh:create_origin>
+ <swh:reference>
+ <swh:origin url="http://example.org" />
+ </swh:reference>
+ </swh:deposit>
+ </entry>
+ """,
+ {
+ "summary": (
+ r".*Reason: assertion test if false.*"
+ r"Schema:\n*"
+ r' *<xsd:assert[^>]+ id="swhdeposit-incompatible-create-and-reference".*'
+ ),
+ "fields": ["swh:deposit"],
+ },
+ ),
+ (
+ f"""\
+ <entry {XMLNS}>
+ <url>something</url>
+ <external_identifier>something-else</external_identifier>
+ <title>bar</title>
+ <author>someone</author>
+ <swh:deposit>
+ <swh:add_to_origin>
+ <swh:origin url="http://example.org" />
+ </swh:add_to_origin>
+ <swh:reference>
+ <swh:origin url="http://example.org" />
+ </swh:reference>
+ </swh:deposit>
+ </entry>
+ """,
+ {
+ "summary": (
+ r".*Reason: assertion test if false.*"
+ r"Schema:\n*"
+ r' *<xsd:assert[^>]+ id="swhdeposit-incompatible-add-and-reference".*'
+ ),
+ "fields": ["swh:deposit"],
+ },
+ ),
(
f"""\
<entry {XMLNS}>
diff --git a/swh/deposit/xsd/swh.xsd b/swh/deposit/xsd/swh.xsd
--- a/swh/deposit/xsd/swh.xsd
+++ b/swh/deposit/xsd/swh.xsd
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
targetNamespace="https://www.softwareheritage.org/schema/2018/deposit"
xmlns:swh="https://www.softwareheritage.org/schema/2018/deposit"
elementFormDefault="qualified"
@@ -7,9 +8,6 @@
<xsd:element name="deposit">
<xsd:complexType>
<xsd:all>
- <!-- note that "create_origin", "add_to_origin", and "reference" are
- mutually exclusive -->
-
<!-- code deposit on a new origin -->
<xsd:element name="create_origin" minOccurs="0">
<xsd:complexType>
@@ -47,6 +45,23 @@
</xsd:element>
</xsd:all>
+
+ <!-- "create_origin", "add_to_origin", and "reference" are mutually exclusive. -->
+ <xsd:assert
+ id="swhdeposit-incompatible-create-and-add"
+ test="not(swh:create_origin) or not(swh:add_to_origin)"
+ vc:minVersion="1.1"
+ />
+ <xsd:assert
+ id="swhdeposit-incompatible-create-and-reference"
+ test="not(swh:create_origin) or not(swh:reference)"
+ vc:minVersion="1.1"
+ />
+ <xsd:assert
+ id="swhdeposit-incompatible-add-and-reference"
+ test="not(swh:add_to_origin) or not(swh:reference)"
+ vc:minVersion="1.1"
+ />
</xsd:complexType>
</xsd:element>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 17 2025, 6:26 PM (7 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216521
Attached To
D7244: Enforce create_origin/add_to_origin/reference are mutually exclusive in the schema
Event Timeline
Log In to Comment