Skip to content

Commit 6f0742c

Browse files
Merge pull request #576 from msdemlei/have-table-utype-in-registry
RegistryResults.get_tables now preserves table utypes.
2 parents c868716 + 776e8cf commit 6f0742c

File tree

3 files changed

+49
-42
lines changed

3 files changed

+49
-42
lines changed

CHANGES.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ Enhancements and Fixes
4141
done via subqueries for less duplication of interfaces. [#562, #572]
4242

4343
- Where datalink records are made from table rows, the table row is
44-
now accessible as datalinks.original_row. []
44+
now accessible as datalinks.original_row. [#559]
45+
46+
- Tables returned by RegistryResource.get_tables() now have a utype
47+
attribute [#576]
4548

4649
Deprecations and Removals
4750
-------------------------

pyvo/registry/regtap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ def _build_vosi_table(self, table_row, columns):
10881088
res.name = table_row["table_name"]
10891089
res.title = table_row["table_title"]
10901090
res.description = table_row["table_description"]
1091+
res.utype = table_row["table_utype"]
10911092
res._columns = [
10921093
self._build_vosi_column(row)
10931094
for row in columns]
@@ -1115,7 +1116,8 @@ def get_tables(self, *, table_limit=20):
11151116
svc = get_RegTAP_service()
11161117

11171118
tables = svc.run_sync(
1118-
"""SELECT table_name, table_description, table_index, table_title
1119+
"""SELECT table_name, table_description, table_index, table_title,
1120+
table_utype
11191121
FROM rr.res_table
11201122
WHERE ivoid={}""".format(
11211123
rtcons.make_sql_literal(self.ivoid)))

pyvo/registry/tests/test_regtap.py

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
@pytest.fixture(name='capabilities')
34-
def _capabilities(mocker):
34+
def _capabilities(mocker, scope="session"):
3535
def callback(request, context):
3636
return get_pkg_data_contents('data/capabilities.xml')
3737

@@ -52,15 +52,15 @@ def callback(request, context):
5252

5353

5454
@pytest.fixture(name='regtap_pulsar_distance_response')
55-
def _regtap_pulsar_distance_response(mocker):
55+
def _regtap_pulsar_distance_response(mocker, scope="session"):
5656
with mocker.register_uri(
5757
'POST', REGISTRY_BASEURL + '/sync',
5858
content=get_pkg_data_contents('data/regtap.xml')) as matcher:
5959
yield matcher
6060

6161

6262
@pytest.fixture()
63-
def keywords_fixture(mocker):
63+
def keywords_fixture(mocker, scope="session"):
6464
def keywordstest_callback(request, context):
6565
data = dict(parse_qsl(request.body))
6666
query = data['QUERY']
@@ -83,7 +83,7 @@ def keywordstest_callback(request, context):
8383

8484

8585
@pytest.fixture()
86-
def single_keyword_fixture(mocker):
86+
def single_keyword_fixture(mocker, scope="session"):
8787
def keywordstest_callback(request, context):
8888
data = dict(parse_qsl(request.body))
8989
query = data['QUERY']
@@ -102,7 +102,7 @@ def keywordstest_callback(request, context):
102102

103103

104104
@pytest.fixture()
105-
def servicetype_fixture(mocker):
105+
def servicetype_fixture(mocker, scope="session"):
106106
def servicetypetest_callback(request, context):
107107
data = dict(parse_qsl(request.body))
108108
query = data['QUERY']
@@ -123,7 +123,7 @@ def servicetypetest_callback(request, context):
123123

124124

125125
@pytest.fixture()
126-
def waveband_fixture(mocker):
126+
def waveband_fixture(mocker, scope="session"):
127127
def wavebandtest_callback(request, content):
128128
data = dict(parse_qsl(request.body))
129129
query = data['QUERY']
@@ -140,7 +140,7 @@ def wavebandtest_callback(request, content):
140140

141141

142142
@pytest.fixture()
143-
def datamodel_fixture(mocker):
143+
def datamodel_fixture(mocker, scope="session"):
144144
def datamodeltest_callback(request, content):
145145
data = dict(parse_qsl(request.body))
146146
query = data['QUERY']
@@ -162,7 +162,7 @@ def datamodeltest_callback(request, content):
162162

163163

164164
@pytest.fixture()
165-
def aux_fixture(mocker):
165+
def aux_fixture(mocker, scope="session"):
166166
def auxtest_callback(request, context):
167167
data = dict(parse_qsl(request.body))
168168
query = data['QUERY']
@@ -179,7 +179,7 @@ def auxtest_callback(request, context):
179179

180180

181181
@pytest.fixture(name='multi_interface_fixture')
182-
def _multi_interface_fixture(mocker):
182+
def _multi_interface_fixture(mocker, scope="session"):
183183
# to update this, run
184184
# import requests
185185
# from pyvo.registry import regtap
@@ -197,7 +197,7 @@ def _multi_interface_fixture(mocker):
197197

198198

199199
@pytest.fixture(name='flash_service')
200-
def _flash_service(multi_interface_fixture):
200+
def _flash_service(multi_interface_fixture, scope="session"):
201201
return regtap.search(
202202
ivoid="ivo://org.gavo.dc/flashheros/q/ssa")[0]
203203

@@ -849,14 +849,14 @@ def test_ambiguous_access_url_warns(self, recwarn):
849849
# TODO: While I suppose the contact test should keep requiring network,
850850
# I think we should can the network responses involved in the following;
851851
# the stuff might change upstream any time and then break our unit tests.
852-
@pytest.fixture(name='flash_tables')
853-
def _flash_tables():
852+
@pytest.fixture(name='obscore_tables')
853+
def _obscore_tables(scope="session"):
854854
rsc = _makeRegistryRecord(
855-
ivoid="ivo://org.gavo.dc/flashheros/q/ssa")
855+
ivoid="ivo://org.gavo.dc/__system__/obscore/obscore")
856856
return rsc.get_tables()
857857

858858

859-
@pytest.mark.usefixtures("flash_tables")
859+
@pytest.mark.usefixtures("obscore_tables")
860860
class TestGetTables:
861861
@pytest.mark.remote_data
862862
def test_get_tables_limit_enforced(self):
@@ -869,47 +869,49 @@ def test_get_tables_limit_enforced(self):
869869
" Pass a higher table_limit to see them all.", str(excinfo.value))
870870

871871
@pytest.mark.remote_data
872-
def test_get_tables_names(self, flash_tables):
873-
assert (list(sorted(flash_tables.keys()))
874-
== ["flashheros.data", "ivoa.obscore"])
872+
def test_get_tables_names(self, obscore_tables):
873+
assert (list(sorted(obscore_tables.keys()))
874+
== ["ivoa.obscore"])
875875

876876
@pytest.mark.remote_data
877-
def test_get_tables_table_instance(self, flash_tables):
878-
assert (flash_tables["ivoa.obscore"].name
877+
def test_get_tables_table_instance(self, obscore_tables):
878+
assert (obscore_tables["ivoa.obscore"].name
879879
== "ivoa.obscore")
880-
assert (flash_tables["ivoa.obscore"].description
881-
== "This data collection is queryable in GAVO Data"
882-
" Center's obscore table.")
883-
assert (flash_tables["flashheros.data"].title
884-
== "Flash/Heros SSA table")
880+
assert (obscore_tables["ivoa.obscore"].description[:42]
881+
== "The IVOA-defined obscore table, containing")
882+
assert (obscore_tables["ivoa.obscore"].title
883+
== "GAVO Data Center Obscore Table")
885884

886-
assert (flash_tables["flashheros.data"].origin.ivoid
887-
== "ivo://org.gavo.dc/flashheros/q/ssa")
885+
assert (obscore_tables["ivoa.obscore"].origin.ivoid
886+
== "ivo://org.gavo.dc/__system__/obscore/obscore")
888887

889888
@pytest.mark.remote_data
890-
def test_get_tables_column_meta(self, flash_tables):
891-
def getflashcol(name):
892-
for col in flash_tables["flashheros.data"].columns:
889+
def test_get_tables_column_meta(self, obscore_tables):
890+
def getcol(name):
891+
for col in obscore_tables["ivoa.obscore"].columns:
893892
if name == col.name:
894893
return col
895894
raise KeyError(name)
896895

897-
assert getflashcol("accref").datatype.content == "char"
898-
assert getflashcol("accref").datatype.arraysize == "*"
896+
assert getcol("access_url").datatype.content == "char"
897+
assert getcol("access_url").datatype.arraysize == "*"
898+
899+
assert getcol("s_region").datatype._extendedtype == "adql:region"
899900

900-
# TODO: upstream bug: the following needs to fixed in DaCHS before
901-
# the assertion passes
902-
# assert getflashcol("ssa_region").datatype._extendedtype == "point"
901+
assert getcol("access_format").ucd == 'meta.code.mime'
903902

904-
assert getflashcol("mime").ucd == 'meta.code.mime'
903+
assert getcol("em_min").unit == "m"
905904

906-
assert getflashcol("ssa_specend").unit == "m"
905+
assert (getcol("t_max").utype
906+
== "obscore:char.timeaxis.coverage.bounds.limits.stoptime")
907907

908-
assert (getflashcol("ssa_specend").utype
909-
== "ssa:char.spectralaxis.coverage.bounds.stop")
908+
assert (getcol("t_exptime").description
909+
== "Total exposure time")
910910

911-
assert (getflashcol("ssa_fluxcalib").description
912-
== "Type of flux calibration")
911+
@pytest.mark.remote_data
912+
def test_get_tables_utype(self, obscore_tables):
913+
assert (obscore_tables["ivoa.obscore"].utype
914+
== "ivo://ivoa.net/std/obscore#table-1.1")
913915

914916

915917
@pytest.mark.remote_data

0 commit comments

Comments
 (0)