astropy / astroquery

Functions and classes to access online data resources. Maintainers: @keflavich and @bsipocz and @ceb8
http://astroquery.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
702 stars 396 forks source link

ESO: How do we run tests requiring login? #1209

Open keflavich opened 6 years ago

keflavich commented 6 years ago

See https://github.com/astropy/astroquery/pull/428. Needed for tests of https://github.com/astropy/astroquery/pull/1184

saimn commented 6 years ago

Okay, so it works, adding username = XXX in the astroquery.cfg file, and using --remote-data !

keflavich commented 6 years ago

Thanks for digging into that! We should document that somewhere other than here.

saimn commented 6 years ago

Actually it failed the first time, when the file was not yet in the cache, and is now passing with the file in cache. There may some edge case not properly handled when the file is not in cache yet ?

INFO: Authentication successful! [astroquery.eso.core]
INFO: Detecting already downloaded datasets... [astroquery.eso.core]
INFO: Checking availability of datasets to download... [astroquery.eso.core]
^[[OINFO: Downloading datasets... [astroquery.eso.core]
INFO: Contacting retrieval server... [astroquery.eso.core]
INFO: Staging request... [astroquery.eso.core]
INFO: Staging form is at http://dataportal.eso.org/rh/requests/MUSETeam/363437 [astroquery.eso.core]
INFO: Downloading file MIDI.2014-07-25T02:03:11.561.fits.Z... [astroquery.eso.core]
Downloading URL http://dataportal.eso.org/dataPortal/requests/MUSETeam/363437/SAF/MIDI.2014-07-25T02:03:11.561/MIDI.2014-07-25T02:03:11.561.fits.Z to /home/simon/.astropy/cache/astroquery/Eso/MIDI.2014-07-25T02:03:11.561.fits.Z ...
|=========================================================|  60M/ 60M (100.00%)      1m15s[[O
INFO: Done! [astroquery.eso.core]
FAILED
astroquery/eso/tests/test_eso_remote.py::TestEso::test_retrieve_data_twice INFO: Authenticating MUSETeam on www.eso.org... [astroquery.eso.core]
INFO: Authentication successful! [astroquery.eso.core]
INFO: Detecting already downloaded datasets... [astroquery.eso.core]
INFO: Found MIDI.2014-07-25T02:03:11.561.fits.Z... [astroquery.eso.core]
INFO: Checking availability of datasets to download... [astroquery.eso.core]
INFO: Downloading datasets... [astroquery.eso.core]
INFO: Done! [astroquery.eso.core]
INFO: Detecting already downloaded datasets... [astroquery.eso.core]
INFO: Checking availability of datasets to download... [astroquery.eso.core]
INFO: Downloading datasets... [astroquery.eso.core]
INFO: Contacting retrieval server... [astroquery.eso.core]
INFO: Staging request... [astroquery.eso.core]
INFO: Staging form is at http://dataportal.eso.org/rh/requests/MUSETeam/363438 [astroquery.eso.core]
INFO: Downloading file AMBER.2006-03-14T07:40:19.830.fits.Z... [astroquery.eso.core]
^[[IDownloading URL http://dataportal.eso.org/dataPortal/requests/MUSETeam/363438/SAF/AMBER.2006-03-14T07:40:19.830/AMBER.2006-03-14T07:40:19.830.fits.Z to /home/simon/.astropy/cache/astroquery/Eso/AMBER.2006-03-14T07:40:19.830.fits.Z ...
|=========================================================| 247k/247k (100.00%)         0s
INFO: Done! [astroquery.eso.core]
PASSED

========================================== FAILURES ===========================================
_________________________________ TestEso.test_retrieve_data __________________________________

self = <astroquery.eso.tests.test_eso_remote.TestEso object at 0x7f39226ec4e0>

    @pytest.mark.skipif(not Eso.USERNAME, reason='need a username')
    def test_retrieve_data(self):
        eso = Eso()
        eso.login()
        result = eso.retrieve_data(["MIDI.2014-07-25T02:03:11.561"])
>       assert len(result) > 0
E       assert 0 > 0
E        +  where 0 = len([])

astroquery/eso/tests/test_eso_remote.py:127: AssertionError
-------------------------------------- Captured log call --------------------------------------
core.py                    238 INFO     Authenticating MUSETeam on www.eso.org...
core.py                    261 INFO     Authentication successful!
core.py                    667 INFO     Detecting already downloaded datasets...
core.py                    672 INFO     Checking availability of datasets to download...
core.py                    682 INFO     Downloading datasets...
core.py                    688 INFO     Contacting retrieval server...
core.py                    691 INFO     Staging request...
core.py                    716 INFO     Staging form is at http://dataportal.eso.org/rh/requests/MUSETeam/363437
core.py                    785 INFO     Downloading file MIDI.2014-07-25T02:03:11.561.fits.Z...
core.py                    801 INFO     Done!
===================== 1 failed, 1 passed, 34 deselected in 96.91 seconds ======================
saimn commented 6 years ago

So this is a real bug, the downloaded files are not appended to the list of files. I don't think I broke this while refactoring the existing files detection, but anyway it will be fixed in a coming PR.