Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: adding remote reaching TAP upload tests #631

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Loading