Skip to content

Commit ffeb08a

Browse files
committed
Added get_query_payload kwarg to astroquery.ogle
1 parent 5cb0987 commit ffeb08a

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

astroquery/ogle/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,16 @@ def _args_to_payload(self, *, coord=None, algorithm='NG', quality='GOOD',
125125
return files
126126

127127
@prepend_docstr_nosections(_args_to_payload.__doc__)
128-
def query_region_async(self, *args, **kwargs):
128+
def query_region_async(self, *args, get_query_payload=False, **kwargs):
129129
"""
130130
Returns
131131
-------
132132
response : `requests.Response`
133133
The HTTP response returned from the service.
134134
"""
135135
files = self._args_to_payload(*args, **kwargs)
136+
if get_query_payload:
137+
return files
136138
# Make request
137139
params = {'dnfile': 'submit'}
138140
response = self._request("POST", url=self.DATA_URL, data=params,

astroquery/ogle/tests/test_ogle.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,53 @@ def test_ogle_list_values(patch_post):
6161
co_list = [[0, 0, 0], [3, 3, 3]]
6262
with pytest.warns(AstropyDeprecationWarning):
6363
ogle.core.Ogle.query_region(coord=co_list)
64+
65+
66+
def test_ogle_single_payload():
67+
"""
68+
Test single pointing payload
69+
"""
70+
co = SkyCoord(0*u.deg, 3*u.deg, frame='galactic')
71+
payload = ogle.core.Ogle.query_region(coord=co, get_query_payload=True)
72+
fk5 = co.transform_to('fk5')
73+
ra = fk5.ra.hour
74+
dec = fk5.dec.degree
75+
assert len(payload) == 1
76+
expected_payload = f'# RD NG GOOD\n{ra} {dec}'
77+
assert payload['file1'] == expected_payload
78+
79+
80+
def test_ogle_multipointing_payload():
81+
"""
82+
Test payload of multiple pointings using a list of astropy coordinates
83+
"""
84+
co1 = SkyCoord(0*u.deg, 3*u.deg, frame='galactic')
85+
co2 = SkyCoord(4*u.deg, 5*u.deg, frame='galactic')
86+
pointings = [co1, co2]
87+
payload = ogle.core.Ogle.query_region(
88+
coord=pointings,
89+
get_query_payload=True
90+
)
91+
conversions = []
92+
for co in pointings:
93+
fk5 = co.transform_to('fk5')
94+
ra_str = f"{fk5.ra.hour}"
95+
dec_str = f"{fk5.dec.degree}"
96+
conversions.append(f"{ra_str} {dec_str}")
97+
expected_payload = "# RD NG GOOD\n" + "\n".join(conversions)
98+
assert payload['file1'] == expected_payload
99+
100+
101+
def test_ogle_nested_list_payload(patch_post):
102+
"""
103+
Test the payload of multiple pointings using a nested-list of decimal
104+
degree Galactic coordinates
105+
"""
106+
co_list = [[0, 0, 0], [3, 3, 3]]
107+
expected_payload = '# RD NG GOOD\n0 3\n0 3\n0 3'
108+
with pytest.warns(AstropyDeprecationWarning):
109+
payload = ogle.core.Ogle.query_region(
110+
coord=co_list,
111+
get_query_payload=True
112+
)
113+
assert payload['file1'] == expected_payload

0 commit comments

Comments
 (0)