Skip to content

Commit ecaaca2

Browse files
committed
Cleanup test_eso.py
1 parent 4e02f93 commit ecaaca2

File tree

1 file changed

+17
-38
lines changed

1 file changed

+17
-38
lines changed

astroquery/eso/tests/test_eso.py

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -86,67 +86,43 @@ def calselector_request(url, **kwargs):
8686
return response
8787

8888

89-
# @pytest.fixture
90-
# def patch_get(request):
91-
# mp = request.getfixturevalue("monkeypatch")
92-
#
93-
# mp.setattr(Eso, 'request', eso_request)
94-
# return mp
95-
96-
# This test should attempt to access the internet and therefore should fail
97-
# (_activate_form always connects to the internet)
98-
# @pytest.mark.xfail
9989
def test_sinfoni_SgrAstar(monkeypatch):
100-
# Local caching prevents a remote query here
101-
102-
eso = Eso()
103-
10490
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
91+
eso = Eso()
10592
monkeypatch.setattr(eso, '_query_tap_service', monkey_tap)
106-
# set up local cache path to prevent remote query
107-
eso.cache_location = DATA_DIR
108-
109-
# the failure should occur here
11093
result = eso.query_instrument('sinfoni', target='SGRA')
111-
112-
# test that max_results = 50
94+
# test all results are there and the expected target is present
11395
assert len(result) == 50
11496
assert 'SGRA' in result['target']
11597

11698

11799
def test_main_SgrAstar(monkeypatch):
118-
# Local caching prevents a remote query here
119-
eso = Eso()
120-
121100
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
101+
eso = Eso()
122102
monkeypatch.setattr(eso, '_query_tap_service', monkey_tap)
123-
# set up local cache path to prevent remote query
124-
eso.cache_location = DATA_DIR
125-
126-
# the failure should occur here
127103
result = eso.query_main(target='SGR A', object='SGR A')
128-
129-
# test that max_results = 5
104+
# test all results are there and the expected target is present
130105
assert len(result) == 23
131106
assert 'SGR A' in result['object']
132107
assert 'SGR A' in result['target']
133108

134109

135110
def test_vvv(monkeypatch):
111+
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
136112
eso = Eso()
137113
monkeypatch.setattr(eso, '_query_tap_service', monkey_tap)
138-
eso.cache_location = DATA_DIR
139-
140-
result_s = eso.query_collections(collections='VVV',
141-
coord1=266.41681662, coord2=-29.00782497,
142-
box='01 00 00',
143-
)
144-
assert result_s is not None
145-
assert 'target_name' in result_s.colnames
146-
assert 'b333' in result_s['target_name']
114+
result = eso.query_collections(collections='VVV',
115+
coord1=266.41681662, coord2=-29.00782497,
116+
box='01 00 00',
117+
)
118+
# test all results are there and the expected target is present
119+
assert len(result) == 50
120+
assert 'target_name' in result.colnames
121+
assert 'b333' in result['target_name']
147122

148123

149124
def test_authenticate(monkeypatch):
125+
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
150126
eso = Eso()
151127
monkeypatch.setattr(eso, '_request', eso_request)
152128
eso.cache_location = DATA_DIR
@@ -155,6 +131,7 @@ def test_authenticate(monkeypatch):
155131

156132

157133
def test_download(monkeypatch, tmp_path):
134+
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
158135
eso = Eso()
159136
eso.cache_location = tmp_path
160137
fileid = 'testfile'
@@ -185,6 +162,7 @@ def test_cached_file():
185162

186163

187164
def test_calselector(monkeypatch, tmp_path):
165+
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
188166
eso = Eso()
189167
eso.cache_location = tmp_path
190168
dataset = 'FORS2.2021-01-02T00:59:12.533'
@@ -196,6 +174,7 @@ def test_calselector(monkeypatch, tmp_path):
196174

197175

198176
def test_calselector_multipart(monkeypatch, tmp_path):
177+
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
199178
eso = Eso()
200179
eso.cache_location = tmp_path
201180
datasets = ['FORS2.2021-01-02T00:59:12.533', 'FORS2.2021-01-02T00:59:12.534']

0 commit comments

Comments
 (0)