Skip to content

Commit ad25430

Browse files
rickynilssonbsipocz
authored andcommitted
Add a few more tests
1 parent 0a55f50 commit ad25430

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

astroquery/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def test_query_criteria():
250250

251251
def mock_run_query(table="ps", select='pl_name,discoverymethod,dec', where="discoverymethod like 'Microlensing' and dec > 0"):
252252
assert table == "ps"
253-
assert select == 'pl_name,discoverymethod,dec'
253+
assert select == "pl_name,discoverymethod,dec"
254254
assert where == "discoverymethod like 'Microlensing' and dec > 0"
255255
result = PropertyMock()
256256
result = {'pl_name': 'TCP J05074264+2447555 b', 'discoverymethod': 'Microlensing', 'dec': [24.7987499] * u.deg}
@@ -260,3 +260,25 @@ def mock_run_query(table="ps", select='pl_name,discoverymethod,dec', where="disc
260260
assert 'TCP J05074264+2447555 b' in response['pl_name']
261261
assert 'Microlensing' in response['discoverymethod']
262262
assert response['dec'] == [24.7987499] * u.deg
263+
264+
265+
@patch('astroquery.nasa_exoplanet_archive.core.get_access_url',
266+
Mock(side_effect=lambda x: 'https://some.url'))
267+
@pytest.mark.skipif(not pyvo_OK, reason='not pyvo_OK')
268+
def test_get_query_payload():
269+
nasa_exoplanet_archive = NasaExoplanetArchive()
270+
271+
def mock_run_query(table="ps", get_query_payload=True, select="count(*)", where="disc_facility like '%TESS%'"):
272+
assert table == "ps"
273+
assert get_query_payload == True
274+
assert select == "count(*)"
275+
assert where == "disc_facility like '%TESS%'"
276+
result = PropertyMock()
277+
result = {'table': 'ps', 'select': 'count(*)', 'where': "disc_facility like '%TESS%'", 'format': 'ipac'}
278+
return result
279+
nasa_exoplanet_archive.query_criteria = mock_run_query
280+
response = nasa_exoplanet_archive.query_criteria()
281+
assert 'ps' in response['table']
282+
assert 'count(*)' in response['select']
283+
assert "disc_facility like '%TESS%'" in response['where']
284+

astroquery/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive_remote.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_select():
9898

9999

100100
@pytest.mark.remote_data
101-
def test_warnings(): # removed patch_get for now
101+
def test_warnings():
102102
with pytest.warns(NoResultsWarning):
103103
NasaExoplanetArchive.query_criteria("ps", where="hostname='not a host'")
104104

@@ -142,7 +142,7 @@ def test_request_to_sql():
142142

143143

144144
@pytest.mark.remote_data
145-
def test_query_region(): # removed patch_get for now
145+
def test_query_region():
146146
coords = SkyCoord(ra=330.79488 * u.deg, dec=18.8843 * u.deg)
147147
radius = 0.001
148148
table1 = NasaExoplanetArchive.query_region("pscomppars", coords, radius * u.deg)
@@ -154,7 +154,15 @@ def test_query_region(): # removed patch_get for now
154154

155155

156156
@pytest.mark.remote_data
157-
def test_format(): # removed patch_get for now
157+
def test_query_aliases():
158+
name = "bet Pic"
159+
aliases = NasaExoplanetArchive.query_aliases(name)
160+
assert len(aliases) == 12
161+
assert "HD 39060" in aliases
162+
163+
164+
@pytest.mark.remote_data
165+
def test_format():
158166
table1 = NasaExoplanetArchive.query_object("HAT-P-11 b")
159167
table2 = NasaExoplanetArchive.query_object("HAT-P-11 b", format="votable")
160168
_compare_tables(table1, table2)

0 commit comments

Comments
 (0)