From 44cd6bdbb4aa3a74ecee6a0318a8ad012bcb343d Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 23 Jan 2024 14:14:58 +0100 Subject: [PATCH 1/2] fix: author constraint missed rr.res_role extra table also add a remote test with all constraints --- CHANGES.rst | 2 ++ pyvo/registry/rtcons.py | 1 + pyvo/registry/tests/test_rtcons.py | 38 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 6a14ccb7d..9bb1625ea 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,8 @@ Enhancements and Fixes ---------------------- +- Fix ``pyvo.registry.Author`` that missed a table join [#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] diff --git a/pyvo/registry/rtcons.py b/pyvo/registry/rtcons.py index 44a6e1cad..6aa59c52d 100644 --- a/pyvo/registry/rtcons.py +++ b/pyvo/registry/rtcons.py @@ -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): diff --git a/pyvo/registry/tests/test_rtcons.py b/pyvo/registry/tests/test_rtcons.py index bbb817749..733d6e869 100644 --- a/pyvo/registry/tests/test_rtcons.py +++ b/pyvo/registry/tests/test_rtcons.py @@ -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') From 050d682eba1625fea178768734b04793df7f9bb3 Mon Sep 17 00:00:00 2001 From: Manon Marchand Date: Tue, 23 Jan 2024 20:49:08 +0100 Subject: [PATCH 2/2] Update CHANGES.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Brigitta Sipőcz --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9bb1625ea..3bd1d4000 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ Enhancements and Fixes ---------------------- -- Fix ``pyvo.registry.Author`` that missed a table join [#515] +- 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