Skip to content

Commit

Permalink
Adding (back?) source_value to RegistryResource.
Browse files Browse the repository at this point in the history
This addresses review comment
#289 (review)
  • Loading branch information
msdemlei committed Jan 24, 2022
1 parent 3d0b068 commit 1b4633a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 28 deletions.
9 changes: 9 additions & 0 deletions pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class RegistryResource(dalq.Record):
"creator_seq",
"content_type",
"source_format",
"source_value",
"region_of_regard",
"waveband",
(f"\n ivo_string_agg(COALESCE(access_url, ''), '{TOKEN_SEP}')",
Expand Down Expand Up @@ -448,6 +449,14 @@ def source_format(self):
"""
return self.get("source_format", decode=True)

@property
def source_value(self):
"""
The bibliographic source for this resource (typically a bibcode
or a DOI).
"""
return self.get("source_value", decode=True)

@property
def region_of_regard(self):
"""
Expand Down
17 changes: 2 additions & 15 deletions pyvo/registry/tests/data/README
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
regtap.xml is used as a generic regtap query response in many of
test_regtap's fixtures; most tests don't actually inspect its contents.

To update it (necessary after changes to regtap.get_RegTAP_query), run
this to update it:

import requests
from pyvo.registry import regtap

with open("regtap.xml", "wb") as f:
f.write(requests.get(regtap.REGISTRY_BASEURL+"/sync", {
"LANG": "ADQL",
"QUERY": regtap.get_RegTAP_query(
keywords="pulsar", ucd=["pos.distance"])}).content)

Instructions for how to update these data items should be found in
the fixtures in test_regtap.py
24 changes: 12 additions & 12 deletions pyvo/registry/tests/data/regtap.xml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions pyvo/registry/tests/test_regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def callback(request, context):
yield matcher


# to update this, run
# import requests
# from pyvo.registry import regtap
#
# with open("data/regtap.xml", "wb") as f:
# f.write(requests.get(regtap.REGISTRY_BASEURL+"/sync", {
# "LANG": "ADQL",
# "QUERY": regtap.get_RegTAP_query(
# keywords="pulsar", ucd=["pos.distance"])}).content)


@pytest.fixture()
def regtap_pulsar_distance_response(mocker):
with mocker.register_uri(
Expand Down Expand Up @@ -304,6 +315,23 @@ def rt_pulsar_distance(regtap_pulsar_distance_response, capabilities):
return regsearch(keywords="pulsar", ucd=["pos.distance"])


def test_record_fields(rt_pulsar_distance):
rec = rt_pulsar_distance["VII/156"]
assert rec.ivoid=="ivo://cds.vizier/vii/156"
assert rec.res_type=="vs:catalogservice"
assert rec.short_name=="VII/156"
assert rec.res_title=="Catalog of 558 Pulsars"
assert rec.content_levels==['research']
assert rec.res_description[:20]=="The catalogue is an up-to-date"[:20]
assert rec.reference_url=="http://cdsarc.unistra.fr/cgi-bin/cat/VII/156"
assert rec.creators==['Taylor J.H.', ' Manchester R.N.', ' Lyne A.G.']
assert rec.content_types==['catalog']
assert rec.source_format=="bibcode"
assert rec.source_value=="1993ApJS...88..529T"
assert rec.waveband==['radio']
# access URL, standard_id and friends exercised in TestInterfaceSelection


class TestResultIndexing:
def test_get_with_index(self, rt_pulsar_distance):
# this is expecte to break when the fixture is updated
Expand Down
5 changes: 4 additions & 1 deletion pyvo/registry/tests/test_rtcons.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def test_junk_rejected(self):
rtcons.Servicetype("junk")
assert str(excinfo.value) == ("Service type junk is neither"
" a full standard URI nor one of the bespoke identifiers"
" image, sia, spectrum, ssap, scs, line, table, tap")
" image, sia, spectrum, ssap, ssa, scs, conesearch, line, slap,"
" table, tap")

def test_legacy_term(self):
assert (rtcons.Servicetype("conesearch").get_search_condition()
Expand Down Expand Up @@ -365,6 +366,7 @@ def test_expected_columns(self):
"creator_seq, "
"content_type, "
"source_format, "
"source_value, "
"region_of_regard, "
"waveband, "
"\n ivo_string_agg(COALESCE(access_url, ''), ':::py VO sep:::') AS access_urls, "
Expand All @@ -387,5 +389,6 @@ def test_group_by_columns(self):
"creator_seq, "
"content_type, "
"source_format, "
"source_value, "
"region_of_regard, "
"waveband")

0 comments on commit 1b4633a

Please sign in to comment.