Skip to content

Commit c95094d

Browse files
rickynilssonbsipocz
authored andcommitted
Get TAP supported tables from TAP query and add table test.
1 parent d3b695d commit c95094d

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

astroquery/nasa_exoplanet_archive/core.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,15 @@ def get_access_url(service='tap'):
9797
return url
9898

9999

100-
# @pytest.mark.remote_data
101-
# def get_tap_tables(url):
102-
# """Tables accessed by API are gradually migrating to TAP service. Generate current list of tables in TAP."""
103-
# tap = pyvo.dal.tap.TAPService(baseurl=url)
104-
# response = tap.search(query="select * from TAP_SCHEMA.tables", language="ADQL")
105-
# tables = [table for table in response["table_name"].data if "TAP_SCHEMA." not in table]
106-
# return tables
100+
def get_tap_tables(url):
101+
"""Tables accessed by API are gradually migrating to TAP service. Generate current list of tables in TAP."""
102+
tap = pyvo.dal.tap.TAPService(baseurl=url)
103+
response = tap.search(query="select * from TAP_SCHEMA.tables", language="ADQL")
104+
tables = [table for table in response["table_name"].data if "TAP_SCHEMA." not in table]
105+
return tables
107106

108107

109-
TAP_TABLES = ['ps', 'pscomppars'] # get_tap_tables(conf.url_tap)
108+
TAP_TABLES = get_tap_tables(conf.url_tap) # TAP_TABLES = ['ps', 'pscomppars']
110109

111110

112111
class InvalidTableError(InvalidQueryError):

astroquery/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,20 @@ def mock_run_query(table="ps", select=["hostname", "pl_name"], where="hostname='
295295
nasa_exoplanet_archive.query_criteria = mock_run_query
296296
payload = nasa_exoplanet_archive.query_criteria()
297297
assert payload["select"] == "hostname,pl_name"
298+
299+
300+
@patch('astroquery.nasa_exoplanet_archive.core.get_access_url',
301+
Mock(side_effect=lambda x: 'https://some.url'))
302+
@pytest.mark.skipif(not pyvo_OK, reason='not pyvo_OK')
303+
def test_get_tap_tables():
304+
nasa_exoplanet_archive = NasaExoplanetArchive()
305+
306+
def mock_run_query(url=conf.url_tap):
307+
assert url == conf.url_tap
308+
result = PropertyMock()
309+
result = ['transitspec', 'emissionspec', 'ps', 'pscomppars', 'keplernames', 'k2names']
310+
return result
311+
nasa_exoplanet_archive.get_tap_tables = mock_run_query
312+
result = nasa_exoplanet_archive.get_tap_tables()
313+
assert 'ps' in result
314+
assert 'pscomppars' in result

0 commit comments

Comments
 (0)