@@ -86,67 +86,43 @@ def calselector_request(url, **kwargs):
86
86
return response
87
87
88
88
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
99
89
def test_sinfoni_SgrAstar (monkeypatch ):
100
- # Local caching prevents a remote query here
101
-
102
- eso = Eso ()
103
-
104
90
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
91
+ eso = Eso ()
105
92
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
110
93
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
113
95
assert len (result ) == 50
114
96
assert 'SGRA' in result ['target' ]
115
97
116
98
117
99
def test_main_SgrAstar (monkeypatch ):
118
- # Local caching prevents a remote query here
119
- eso = Eso ()
120
-
121
100
# monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
101
+ eso = Eso ()
122
102
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
127
103
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
130
105
assert len (result ) == 23
131
106
assert 'SGR A' in result ['object' ]
132
107
assert 'SGR A' in result ['target' ]
133
108
134
109
135
110
def test_vvv (monkeypatch ):
111
+ # monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
136
112
eso = Eso ()
137
113
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' ]
147
122
148
123
149
124
def test_authenticate (monkeypatch ):
125
+ # monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
150
126
eso = Eso ()
151
127
monkeypatch .setattr (eso , '_request' , eso_request )
152
128
eso .cache_location = DATA_DIR
@@ -155,6 +131,7 @@ def test_authenticate(monkeypatch):
155
131
156
132
157
133
def test_download (monkeypatch , tmp_path ):
134
+ # monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
158
135
eso = Eso ()
159
136
eso .cache_location = tmp_path
160
137
fileid = 'testfile'
@@ -185,6 +162,7 @@ def test_cached_file():
185
162
186
163
187
164
def test_calselector (monkeypatch , tmp_path ):
165
+ # monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
188
166
eso = Eso ()
189
167
eso .cache_location = tmp_path
190
168
dataset = 'FORS2.2021-01-02T00:59:12.533'
@@ -196,6 +174,7 @@ def test_calselector(monkeypatch, tmp_path):
196
174
197
175
198
176
def test_calselector_multipart (monkeypatch , tmp_path ):
177
+ # monkeypatch instructions from https://pytest.org/latest/monkeypatch.html
199
178
eso = Eso ()
200
179
eso .cache_location = tmp_path
201
180
datasets = ['FORS2.2021-01-02T00:59:12.533' , 'FORS2.2021-01-02T00:59:12.534' ]
0 commit comments