Skip to content

Commit

Permalink
finally good hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
jwfraustro committed Sep 26, 2024
1 parent 9fc64c0 commit 0bcd708
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
1 change: 0 additions & 1 deletion tests/tapregext/tapregext_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

TAPREGEXT_NAMESPACE_HEADER = """xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vm="http://www.ivoa.net/xml/VOMetadata/v0.1"
xmlns="http://www.ivoa.net/xml/TAPRegExt/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
"""

Expand Down
38 changes: 19 additions & 19 deletions tests/voresource/voresource_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TestValidation(TestCase):

test_validation_model = Validation(value=0, validated_by="https://example.edu")
test_validation_xml = (
'<Validation xmlns="http://www.ivoa.net/xml/VOResource/v1.0" validatedBy="https://example.edu/">0</Validation>'
'<Validation validatedBy="https://example.edu/">0</Validation>'
)

def test_read_from_xml(self):
Expand All @@ -65,7 +65,7 @@ class TestResourceName(TestCase):
"""Test VOResource ResourceName model."""

test_resource_name_model = ResourceName(value="Example Resource", ivo_id="ivo://example.edu/resource")
test_resource_name_xml = '<ResourceName xmlns="http://www.ivoa.net/xml/VOResource/v1.0" ivo-id="ivo://example.edu/resource">Example Resource</ResourceName>'
test_resource_name_xml = '<ResourceName ivo-id="ivo://example.edu/resource">Example Resource</ResourceName>'

def test_read_from_xml(self):
"""Test reading from XML."""
Expand All @@ -87,7 +87,7 @@ class TestDate(TestCase):

test_date_model = Date(value="2021-01-01T00:00:00Z", role="update")
test_date_xml = (
'<Date xmlns="http://www.ivoa.net/xml/VOResource/v1.0" role="update">2021-01-01T00:00:00.000Z</Date>'
'<Date role="update">2021-01-01T00:00:00.000Z</Date>'
)

def test_read_from_xml(self):
Expand All @@ -110,7 +110,7 @@ class TestSource(TestCase):

test_source_model = Source(value="https://example.edu", format="bibcode")
test_source_xml = (
'<Source xmlns="http://www.ivoa.net/xml/VOResource/v1.0" format="bibcode">https://example.edu/</Source>'
'<Source format="bibcode">https://example.edu/</Source>'
)

def test_read_from_xml(self):
Expand All @@ -132,7 +132,7 @@ class TestRights(TestCase):
"""Test VOResource Rights model"""

test_rights_model = Rights(value="CC BY 4.0", rights_uri="https://creativecommons.org/licenses/by/4.0/")
test_rights_xml = '<Rights xmlns="http://www.ivoa.net/xml/VOResource/v1.0" rightsURI="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</Rights>'
test_rights_xml = '<Rights rightsURI="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</Rights>'

def test_read_from_xml(self):
"""Test reading from XML."""
Expand All @@ -154,7 +154,7 @@ class TestAccessURL(TestCase):

test_access_url_model = AccessURL(value="https://example.edu", use="full")
test_access_url_xml = (
'<AccessURL xmlns="http://www.ivoa.net/xml/VOResource/v1.0" use="full">https://example.edu/</AccessURL>'
'<AccessURL use="full">https://example.edu/</AccessURL>'
)

def test_read_from_xml(self):
Expand All @@ -177,7 +177,7 @@ class TestMirrorURL(TestCase):

test_mirror_url_model = MirrorURL(value="https://example.edu", title="Mirror")
test_mirror_url_xml = (
'<MirrorURL xmlns="http://www.ivoa.net/xml/VOResource/v1.0" title="Mirror">https://example.edu/</MirrorURL>'
'<MirrorURL title="Mirror">https://example.edu/</MirrorURL>'
)

def test_read_from_xml(self):
Expand Down Expand Up @@ -206,7 +206,7 @@ class TestContact(TestCase):
alt_identifier=["http://orcid.org/0000-0001-9718-6515"],
)
test_contact_xml = (
'<Contact xmlns="http://www.ivoa.net/xml/VOResource/v1.0">'
'<Contact >'
"<name>John Doe</name>"
"<address>1234 Example St.</address>"
"<email>[email protected]</email>"
Expand Down Expand Up @@ -238,7 +238,7 @@ class TestCreator(TestCase):

test_creator_model = Creator(name=ResourceName(value="Doe, J."), logo="https://example.edu/logo.png")
test_creator_xml = (
'<Creator xmlns="http://www.ivoa.net/xml/VOResource/v1.0">'
'<Creator >'
"<name>Doe, J.</name>"
"<logo>https://example.edu/logo.png</logo>"
"</Creator>"
Expand Down Expand Up @@ -267,7 +267,7 @@ class TestRelationship(TestCase):
related_resource=[ResourceName(value="Example Resource", ivo_id="ivo://example.edu/resource")],
)
test_relationship_xml = (
'<Relationship xmlns="http://www.ivoa.net/xml/VOResource/v1.0">'
'<Relationship >'
"<relationshipType>isPartOf</relationshipType>"
'<relatedResource ivo-id="ivo://example.edu/resource">Example Resource</relatedResource>'
"</Relationship>"
Expand All @@ -293,7 +293,7 @@ class TestSecurityMethod(TestCase):
"""Test VOResource SecurityMethod model"""

test_security_method_model = SecurityMethod(standard_id="ivo://ivoa.net/std/Security#basic")
test_security_method_xml = '<SecurityMethod xmlns="http://www.ivoa.net/xml/VOResource/v1.0" standardID="ivo://ivoa.net/std/Security#basic"/>'
test_security_method_xml = '<SecurityMethod standardID="ivo://ivoa.net/std/Security#basic"/>'

def test_read_from_xml(self):
"""Test reading from XML."""
Expand Down Expand Up @@ -322,7 +322,7 @@ class TestCuration(TestCase):
)

test_curation_xml = (
'<Curation xmlns="http://www.ivoa.net/xml/VOResource/v1.0">'
'<Curation >'
"<publisher>STScI</publisher>"
"<creator><name>Doe, J.</name></creator>"
"<contributor>Example Resource</contributor>"
Expand Down Expand Up @@ -371,7 +371,7 @@ class TestContent(TestCase):
)

test_content_xml = (
'<Content xmlns="http://www.ivoa.net/xml/VOResource/v1.0">'
'<Content >'
"<subject>Astronomy</subject>"
"<description>Example description</description>"
'<source format="bibcode">https://example.edu/</source>'
Expand Down Expand Up @@ -420,7 +420,7 @@ class TestInterface(TestCase):
test_querystring="test",
)
test_interface_xml = (
'<interface xmlns="http://www.ivoa.net/xml/VOResource/v1.0" role="std" version="1.0">'
'<interface role="std" version="1.0">'
'<accessURL use="full">https://example.edu/</accessURL>'
'<mirrorURL title="Mirror">https://example.edu/</mirrorURL>'
'<securityMethod standardID="ivo://ivoa.net/std/Security#basic"/>'
Expand Down Expand Up @@ -457,7 +457,7 @@ class TestWebService(TestCase):
access_url=[AccessURL(value="https://example.edu/", use="full")],
)
test_web_service_xml = (
'<interface xmlns="http://www.ivoa.net/xml/VOResource/v1.0" '
'<interface '
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
'xsi:type="vr:WebService">'
'<accessURL use="full">https://example.edu/</accessURL>'
Expand Down Expand Up @@ -520,7 +520,7 @@ class TestResource(TestCase):
)

test_resource_xml = (
'<Resource xmlns="http://www.ivoa.net/xml/VOResource/v1.0" created="1996-03-11T19:00:00.000Z" updated="1996-03-11T19:00:00.000Z" status="active" version="1.0" >'
'<Resource created="1996-03-11T19:00:00.000Z" updated="1996-03-11T19:00:00.000Z" status="active" version="1.0" >'
'<validationLevel validatedBy="https://example.edu/">0</validationLevel>'
"<title>Example Resource</title>"
"<shortName>example</shortName>"
Expand Down Expand Up @@ -612,7 +612,7 @@ class TestOrganization(TestCase):
)

test_organization_xml = (
'<Organisation xmlns="http://www.ivoa.net/xml/VOResource/v1.0" status="active" version="1.0" created="1996-03-11T19:00:00.000Z" updated="1996-03-11T19:00:00.000Z">'
'<Organisation status="active" version="1.0" created="1996-03-11T19:00:00.000Z" updated="1996-03-11T19:00:00.000Z">'
"<title>Example Organization</title>"
"<identifier>https://example.edu/</identifier>"
"<curation>"
Expand Down Expand Up @@ -670,7 +670,7 @@ class TestCapability(TestCase):
)

test_capability_xml = (
'<capability xmlns="http://www.ivoa.net/xml/VOResource/v1.0" standardID="ivo://ivoa.net/std/TAP">'
'<capability standardID="ivo://ivoa.net/std/TAP">'
'<validationLevel validatedBy="https://example.edu/">0</validationLevel>'
"<description>Example description</description>"
'<interface role="std" version="1.0">'
Expand Down Expand Up @@ -734,7 +734,7 @@ class TestService(TestCase):
)

test_service_xml = (
'<Service xmlns="http://www.ivoa.net/xml/VOResource/v1.0" created="1996-03-11T19:00:00.000Z" updated="1996-03-11T19:00:00.000Z" status="active">'
'<Service created="1996-03-11T19:00:00.000Z" updated="1996-03-11T19:00:00.000Z" status="active">'
"<title>Example Service</title>"
"<identifier>https://example.edu/</identifier>"
"<curation>"
Expand Down
2 changes: 1 addition & 1 deletion tests/vosi/capabilities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from vo_models.vosi.capabilities.models import VOSICapabilities

CAPABILITIES_HEADER = """xmlns:vosi="http://www.ivoa.net/xml/VOSICapabilities/v1.0"
xmlns="http://www.ivoa.net/xml/VOResource/v1.0"
xmlns:vs="http://www.ivoa.net/xml/VODataService/v1.0"
xmlns:vr="http://www.ivoa.net/xml/VOResource/v1.0"
xmlns:tr="http://www.ivoa.net/xml/TAPRegExt/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
"""
Expand Down
5 changes: 3 additions & 2 deletions vo_models/tapregext/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
from pydantic_xml import BaseXmlModel, attr, element

from vo_models.voresource.models import Capability
from vo_models.voresource.models import NSMAP as VORESOURCE_NSMAP

NSMAP = {
"xs": "http://www.w3.org/2001/XMLSchema",
"vm": "http://www.ivoa.net/xml/VOMetadata/v0.1",
"": "http://www.ivoa.net/xml/TAPRegExt/v1.0",
"tr": "http://www.ivoa.net/xml/TAPRegExt/v1.0",
"xsi": "http://www.w3.org/2001/XMLSchema-instance",
}
} | VORESOURCE_NSMAP


class DataModelType(BaseXmlModel, nsmap=NSMAP):
Expand Down
2 changes: 1 addition & 1 deletion vo_models/voresource/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# pylint: disable=too-few-public-methods

NSMAP = {
"": "http://www.ivoa.net/xml/VOResource/v1.0",
"vr": "http://www.ivoa.net/xml/VOResource/v1.0",
"xs": "http://www.w3.org/2001/XMLSchema",
"vm": "http://www.ivoa.net/xml/VOMetadata/v0.1",
"xsi": "http://www.w3.org/2001/XMLSchema-instance",
Expand Down
2 changes: 0 additions & 2 deletions vo_models/vosi/capabilities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"vosi": "http://www.ivoa.net/xml/VOSICapabilities/v1.0",
"xsd": "http://www.w3.org/2001/XMLSchema",
"xsi": "http://www.w3.org/2001/XMLSchema-instance",
"tr": "http://www.ivoa.net/xml/TAPRegExt/v1.0",
} | VORESOURCE_NSMAP


Expand All @@ -29,6 +28,5 @@ class VOSICapabilities(BaseXmlModel, tag="capabilities", ns="vosi", nsmap=NSMAP)
capability: list[Union[TableAccess, Capability]] = element(
tag="capability",
ns="",
nsmap=NSMAP,
default=[],
)

0 comments on commit 0bcd708

Please sign in to comment.