Skip to content

Commit

Permalink
Merge pull request astropy#515 from cds-astro/fix-author-constraint
Browse files Browse the repository at this point in the history
fix: author constraint missed rr.res_role extra table
  • Loading branch information
bsipocz authored Jan 23, 2024
2 parents e9e0eb5 + 050d682 commit a3c9d85
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Enhancements and Fixes
----------------------

- Fix ``pyvo.registry.Author`` to allow registry searches with author constraints. [#515]

- Add method ``list_services`` to ``pyvo.registry.regtap.RegistryResource`` that returns the
list of available services. Add ``keyword`` parameter in ``get_service`` which should match
``capability_description``. [#505]
Expand Down
1 change: 1 addition & 0 deletions pyvo/registry/rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def __init__(self, name: str):
"""
self._condition = "role_name LIKE {auth} AND base_role='creator'"
self._fillers = {"auth": name}
self._extra_tables = ["rr.res_role"]


class Servicetype(Constraint):
Expand Down
38 changes: 38 additions & 0 deletions pyvo/registry/tests/test_rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,41 @@ def test_group_by_columns(self):
"region_of_regard, "
"waveband, "
"alt_identifier"))

def test_joined_tables(self):
expected_tables = [
# from author constraint
"rr.res_role",
# default tables
"rr.resource",
"rr.capability",
"rr.interface",
"rr.alt_identifier"
]
assert all(table in _build_regtap_query_with_fake([rtcons.Author("%Hubble%")])
for table in expected_tables)


@pytest.mark.remote_data
def test_all_constraints():
text = rtcons.Freetext("star")
author = rtcons.Author(r"%ESA%")
servicetype = rtcons.Servicetype("tap")
waveband = rtcons.Waveband("optical")
datamodel = rtcons.Datamodel("obscore")
ivoid = rtcons.Ivoid(r"ivoid")
ucd = rtcons.UCD(r"pos.eq.ra")
moc = rtcons.Spatial("0/0-11", intersect="overlaps")
spectral = rtcons.Spectral((5000 * u.Angstrom, 6000 * u.Angstrom))
time = rtcons.Temporal((50000, 60000))
result = registry.search(
text, author, servicetype, waveband, datamodel,
ivoid, ucd, moc, spectral, time
)
assert result.fieldnames == (
'ivoid', 'res_type', 'short_name',
'res_title', 'content_level', 'res_description',
'reference_url', 'creator_seq', 'created', 'updated',
'rights', 'content_type', 'source_format', 'source_value',
'region_of_regard', 'waveband', 'access_urls', 'standard_ids',
'intf_types', 'intf_roles', 'cap_descriptions', 'alt_identifier')

0 comments on commit a3c9d85

Please sign in to comment.