Skip to content

Commit

Permalink
TST: adding remote testing upload test, inherited from astroquery
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Dec 10, 2024
1 parent 2a0d91c commit 7f68019
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion pyvo/dal/tests/test_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from contextlib import ExitStack
import datetime
import re
from io import BytesIO
from io import BytesIO, StringIO
from urllib.parse import parse_qsl
import tempfile

Expand Down Expand Up @@ -802,3 +802,37 @@ def test_get_endpoint_candidates():
"http://astroweb.projects.phys.ucl.ac.uk:8000/capabilities"
]
assert svc._get_endpoint_candidates("capabilities") == expected_urls


@pytest.mark.remote_data
@pytest.mark.parametrize('stream_type', [BytesIO, StringIO])
def test_tap_upload_remote(stream_type):
tmp_table = ('''<?xml version="1.0" encoding="UTF-8"?>
<VOTABLE xmlns="http://www.ivoa.net/xml/VOTable/v1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3">
<RESOURCE>
<TABLE>
<FIELD name="prop_id" datatype="char" arraysize="*">
<DESCRIPTION>external URI for the physical artifact</DESCRIPTION>
</FIELD>
<DATA>
<TABLEDATA>
<TR>
<TD>2013.1.01365.S</TD>
</TR>
</TABLEDATA>
</DATA>
</TABLE>
</RESOURCE>
</VOTABLE>''')

if stream_type == BytesIO:
tmp_table = tmp_table.encode()
query = ('select top 3 proposal_id from ivoa.ObsCore oc join '
'TAP_UPLOAD.proj_codes pc on oc.proposal_id=pc.prop_id')
service = TAPService('https://almascience.nrao.edu/tap')

res = service.search(query, uploads={'proj_codes': stream_type(tmp_table)})
assert len(res) == 3
for row in res:
assert row['proposal_id'] == '2013.1.01365.S'

0 comments on commit 7f68019

Please sign in to comment.