Skip to content

Commit 0ad38d8

Browse files
authored
Merge pull request #2160 from eerovaher/deprecate-send-request
Deprecate `astroquery.utils.commons.send_request`
2 parents 241d896 + 910791c commit 0ad38d8

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

astroquery/utils/commons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import astropy.units as u
1717
from astropy import coordinates as coord
1818
from collections import OrderedDict
19-
from astropy.utils import minversion
19+
from astropy.utils import deprecated, minversion
2020
import astropy.utils.data as aud
2121
from astropy.io import fits, votable
2222

@@ -60,6 +60,7 @@ def FK4CoordGenerator(*args, **kwargs):
6060
ASTROPY_LT_4_3 = not minversion('astropy', '4.3')
6161

6262

63+
@deprecated('0.4.4', alternative='astroquery.query.BaseQuery._request')
6364
def send_request(url, data, timeout, request_type='POST', headers={},
6465
**kwargs):
6566
"""

astroquery/utils/tests/test_utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import astropy.units as u
1616
from astropy.table import Table
1717
import astropy.utils.data as aud
18+
from astropy.utils.exceptions import AstropyDeprecationWarning
1819

1920
from ...utils import chunk_read, chunk_report, class_or_instance, commons
2021
from ...utils.process_asyncs import async_to_sync_docstr, async_to_sync
@@ -96,8 +97,9 @@ def raise_for_status(self):
9697
status_code=status_code)
9798
monkeypatch.setattr(requests, 'post', mock_post)
9899

99-
response = commons.send_request('https://github.com/astropy/astroquery',
100-
data=dict(msg='ok'), timeout=30)
100+
with pytest.warns(AstropyDeprecationWarning):
101+
response = commons.send_request('https://github.com/astropy/astroquery',
102+
data=dict(msg='ok'), timeout=30)
101103
assert response.url == 'https://github.com/astropy/astroquery'
102104
assert response.data == dict(msg='ok')
103105
assert 'astroquery' in response.headers['User-Agent']
@@ -112,8 +114,9 @@ def mock_get(url, params, timeout, headers={}, status_code=200):
112114
req.raise_for_status = lambda: None
113115
return req
114116
monkeypatch.setattr(requests, 'get', mock_get)
115-
response = commons.send_request('https://github.com/astropy/astroquery',
116-
dict(a='b'), 60, request_type='GET')
117+
with pytest.warns(AstropyDeprecationWarning):
118+
response = commons.send_request('https://github.com/astropy/astroquery',
119+
dict(a='b'), 60, request_type='GET')
117120
assert response.url == 'https://github.com/astropy/astroquery?a=b'
118121

119122

@@ -125,15 +128,18 @@ def mock_get(url, params, timeout, headers={}, status_code=200):
125128
req.raise_for_status = lambda: None
126129
return req
127130
monkeypatch.setattr(requests, 'get', mock_get)
128-
response = commons.send_request('https://github.com/astropy/astroquery',
129-
dict(a='b'), 1 * u.min, request_type='GET')
131+
with pytest.warns(AstropyDeprecationWarning):
132+
response = commons.send_request('https://github.com/astropy/astroquery',
133+
dict(a='b'), 1 * u.min,
134+
request_type='GET')
130135
assert response.url == 'https://github.com/astropy/astroquery?a=b'
131136

132137

133138
def test_send_request_err():
134139
with pytest.raises(ValueError):
135-
commons.send_request('https://github.com/astropy/astroquery',
136-
dict(a='b'), 60, request_type='PUT')
140+
with pytest.warns(AstropyDeprecationWarning):
141+
commons.send_request('https://github.com/astropy/astroquery',
142+
dict(a='b'), 60, request_type='PUT')
137143

138144

139145
col_1 = [1, 2, 3]

0 commit comments

Comments
 (0)