Skip to content

Commit bd1643d

Browse files
NXSAPCR-1091: Added remaining functionality to the branch
1 parent 3323d7d commit bd1643d

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

astroquery/esa/xmm_newton/core.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,27 @@
2020
from pathlib import Path
2121
import tarfile
2222
import os
23+
from astroquery import log
24+
import configparser
2325

2426
from astropy.io import fits
2527
from . import conf, config
2628
from astroquery import log
2729
from astropy.coordinates import SkyCoord
2830
from ...exceptions import LoginError
2931

30-
3132
__all__ = ['XMMNewton', 'XMMNewtonClass']
3233

3334

3435
class XMMNewtonClass(BaseQuery):
35-
3636
data_url = conf.DATA_ACTION
3737
data_aio_url = conf.DATA_ACTION_AIO
3838
metadata_url = conf.METADATA_ACTION
3939
TIMEOUT = conf.TIMEOUT
4040

4141
def __init__(self, tap_handler=None):
4242
super(XMMNewtonClass, self).__init__()
43+
self.configuration = configparser.ConfigParser()
4344

4445
if tap_handler is None:
4546
self._tap = TapPlus(url="https://nxsa.esac.esa.int/tap-server/tap")
@@ -48,7 +49,7 @@ def __init__(self, tap_handler=None):
4849
self._rmf_ftp = str("http://sasdev-xmm.esac.esa.int/pub/ccf/constituents/extras/responses/")
4950

5051
def download_data(self, observation_id, *, filename=None, verbose=False,
51-
cache=True, prop=False, username=None, password=None, **kwargs):
52+
cache=True, prop=False, credentials_file=None, **kwargs):
5253
"""
5354
Download data from XMM-Newton
5455
@@ -113,7 +114,11 @@ def download_data(self, observation_id, *, filename=None, verbose=False,
113114
# If the user wants to access proprietary data, ask them for there credentials
114115
if prop:
115116
username, password = self._get_username_and_password(credentials_file)
117+
<<<<<<< HEAD
116118
link = f"{link}&AIOUSER={username}&AIOPWD={password}"
119+
=======
120+
link = link + "&AIOUSER=" + username + "&AIOPWD=" + password
121+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
117122

118123
if verbose:
119124
log.info(link)
@@ -130,7 +135,11 @@ def download_data(self, observation_id, *, filename=None, verbose=False,
130135
self._download_file(link, filename, head_safe=True, cache=cache)
131136

132137
if verbose:
138+
<<<<<<< HEAD
133139
log.info(f"Wrote {link} to {filename}")
140+
=======
141+
log.info("Wrote {0} to {1}".format(link, filename))
142+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
134143
log.setLevel(previouslevel)
135144

136145
def get_postcard(self, observation_id, *, image_type="OBS_EPIC",
@@ -277,7 +286,11 @@ def get_columns(self, table_name, *, only_names=True, verbose=False):
277286
return columns
278287

279288
def _create_link(self, observation_id, **kwargs):
289+
<<<<<<< HEAD
280290
link = f"{self.data_aio_url}obsno={observation_id}"
291+
=======
292+
link = self.data_aio_url + "obsno=" + observation_id
293+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
281294
link = link + "".join("&{0}={1}".format(key, val)
282295
for key, val in kwargs.items())
283296
return link

astroquery/esa/xmm_newton/tests/test_xmm_newton.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
1010
Created on 4 Sept. 2019
1111
"""
12+
<<<<<<< HEAD
1213
from unittest.mock import patch
14+
=======
15+
from unittest.mock import patch, MagicMock
16+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
1317

1418
import pytest
1519
import tarfile
@@ -23,7 +27,11 @@
2327
from astroquery.exceptions import LoginError
2428

2529

30+
<<<<<<< HEAD
2631
class mockResponse():
32+
=======
33+
class mockResponse:
34+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
2735
headers = {'Date': 'Wed, 24 Nov 2021 13:43:50 GMT',
2836
'Server': 'Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips',
2937
'Content-Disposition': 'inline; filename="0560181401.tar.gz"',
@@ -34,8 +42,13 @@ class mockResponse():
3442
@staticmethod
3543
def raise_for_status():
3644
pass
45+
<<<<<<< HEAD
3746

3847

48+
=======
49+
50+
51+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
3952
class TestXMMNewton():
4053
def get_dummy_tap_handler(self):
4154
parameters = {'query': "select top 10 * from v_public_observations",
@@ -530,6 +543,7 @@ def test_request_link(self, mock_request):
530543
params = xsa._request_link("https://nxsa.esac.esa.int/nxsa-sl/servlet/data-action-aio?obsno=0560181401", None)
531544
assert params == {'filename': '0560181401.tar.gz'}
532545

546+
<<<<<<< HEAD
533547
@pytest.mark.xfail(raises=LoginError)
534548
@patch('astroquery.query.BaseQuery._request')
535549
def test_request_link_protected(self, mock_request):
@@ -549,6 +563,8 @@ def test_request_link_incorrect_credentials(self, mock_request):
549563
mock_request.return_value = dummyclass
550564
xsa._request_link("https://nxsa.esac.esa.int/nxsa-sl/servlet/data-action-aio?obsno=0560181401", None)
551565

566+
=======
567+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
552568
def test_get_username_and_password(self):
553569
xsa = XMMNewtonClass(self.get_dummy_tap_handler())
554570
username, password = xsa._get_username_and_password("astroquery/esa/xmm_newton/tests/my_config.ini")

astroquery/esa/xmm_newton/tests/test_xmm_newton_remote.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def test_download_proprietary_data_incorrect_credentials(self):
199199
parameters = {'observation_id': "0762470101",
200200
'prop': 'True',
201201
'credentials_file': "astroquery/esa/xmm_newton/tests/my_config.ini",
202+
<<<<<<< HEAD
202203
'level': "PPS",
203204
'name': 'OBSMLI',
204205
'filename': 'single',
@@ -212,6 +213,8 @@ def test_download_proprietary_data_incorrect_credentials(self):
212213
@pytest.mark.xfail(raises=LoginError)
213214
def test_download_proprietary_data_without_credentials(self):
214215
parameters = {'observation_id': "0883780101",
216+
=======
217+
>>>>>>> 40576ad4 (xmm_newton-1.1_issue1093 Refactored the download data method and added the corresponding tests)
215218
'level': "PPS",
216219
'name': 'OBSMLI',
217220
'filename': 'single',

0 commit comments

Comments
 (0)