Skip to content

Commit

Permalink
Change Series Volume sub-element type to nonNegativeInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
bpepple committed Nov 14, 2024
1 parent d5f7219 commit 94db9c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drafts/v1.0/MetronInfo.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<xs:all>
<xs:element name="Name" type="xs:string" />
<xs:element name="SortName" type="xs:string" minOccurs="0" />
<xs:element name="Volume" type="xs:int" minOccurs="0" />
<xs:element name="Volume" type="xs:nonNegativeInteger" minOccurs="0" />
<xs:element name="Format" type="formatType" minOccurs="0" />
<xs:element name="StartYear" type="xs:gYear" minOccurs="0" />
<xs:element name="IssueCount" type="xs:positiveInteger" minOccurs="0" />
Expand Down
14 changes: 12 additions & 2 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
'<?xml version="1.0" encoding="UTF-8"?><MetronInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
"<Series><Name>Foo</Name></Series><Number /><PageCount>0</PageCount></MetronInfo>",
),
(
TEST_XSD,
'<?xml version="1.0" encoding="UTF-8"?><MetronInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
"<Series><Name>Foo</Name><Volume>0</Volume></Series><Number /></MetronInfo>",
),
],
ids=["valid_xml", "zero_page_count"],
ids=["valid_xml", "zero_page_count", "volume_zero"],
)
def test_valid(xsd: Path, xml: Path | str) -> None:
schema = XMLSchema11(xsd)
Expand All @@ -33,8 +38,13 @@ def test_valid(xsd: Path, xml: Path | str) -> None:
'<?xml version="1.0" encoding="UTF-8"?><MetronInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
"<Series><Name>Foo</Name></Series><Number /><PageCount>-1</PageCount></MetronInfo>",
),
(
TEST_XSD,
'<?xml version="1.0" encoding="UTF-8"?><MetronInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
"<Series><Name>Foo</Name><Volume>-1</Volume></Series><Number /></MetronInfo>",
),
],
ids=["dup_primary_attr_xml", "negative_page_count"],
ids=["dup_primary_attr_xml", "negative_page_count", "negative_volume"],
)
def test_invalid(xsd: Path, xml: Path | str) -> None:
schema = XMLSchema11(xsd)
Expand Down

0 comments on commit 94db9c4

Please sign in to comment.