Skip to content

Commit 4db7992

Browse files
authored
Merge pull request astropy#669 from chmmao/sia2_standardid
[Issue 668] [SIA2 service] check existence of standardid
2 parents 5f5f67a + d8ba077 commit 4db7992

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Enhancements and Fixes
1717
- Correctly delete jobs in ``TAPService.run_async`` even when the server returns an
1818
error [#667]
1919

20+
- Fixed AttributeError when a capability has None standardID in SIA2Service. [#669]
21+
22+
2023
Deprecations and Removals
2124
-------------------------
2225

pyvo/dal/sia2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def __init__(self, baseurl, *, capability_description=None, session=None, check_
186186
# assumes that the access URL is the same regardless of the
187187
# authentication method except BasicAA which is not supported
188188
# in pyvo. So pick any access url as long as it's not
189-
if cap.standardid.lower() == SIA2_STANDARD_ID.lower():
189+
if cap.standardid and cap.standardid.lower() == SIA2_STANDARD_ID.lower():
190190
for interface in cap.interfaces:
191191
if interface.accessurls and \
192192
not (len(interface.securitymethods) == 1

pyvo/dal/tests/test_sia2.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,32 @@ def test_variable_deprecation():
213213
with pytest.warns(AstropyDeprecationWarning):
214214
from pyvo.dal.sia2 import SIA_PARAMETERS_DESC
215215
assert SIA_PARAMETERS_DESC
216+
217+
218+
def test_none_standardid_capability():
219+
"""Test that SIA2Service handles capabilities with None standardID."""
220+
from pyvo.dal.sia2 import SIA2Service
221+
import requests_mock
222+
# Mock a capabilities response with a None standardID
223+
with requests_mock.Mocker() as m:
224+
# Mock the capabilities endpoint
225+
m.get('http://example.com/sia/capabilities',
226+
content=b'''<?xml version="1.0" encoding="UTF-8"?>
227+
<vosi:capabilities xmlns:vosi="http://www.ivoa.net/xml/VOSICapabilities/v1.0">
228+
<capability>
229+
<!-- This capability has no standardID attribute -->
230+
<interface>
231+
<accessURL use="full">http://example.com/sia/query</accessURL>
232+
</interface>
233+
</capability>
234+
<capability standardID="ivo://ivoa.net/std/SIA#query-2.0">
235+
<interface>
236+
<accessURL use="full">http://example.com/sia/query</accessURL>
237+
</interface>
238+
</capability>
239+
</vosi:capabilities>''')
240+
# This should not raise an AttributeError
241+
sia2_service = SIA2Service('http://example.com/sia')
242+
# Basic verification that the service was created successfully
243+
assert sia2_service is not None
244+
assert sia2_service.query_ep is not None

0 commit comments

Comments
 (0)