Skip to content

Commit 8972079

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
authored andcommitted
GAIAMNGT-1535 C9GACS-928 The function upload_table in the TapPlus class does not allow table names that contain a dot
1 parent b530378 commit 8972079

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ gaia
211211

212212
- Default Gaia catalog updated to DR3. [#2596]
213213

214+
- The function upload_table in the TapPlus class does not allow table names that contain a dot. [#2596]
215+
216+
214217
heasarc
215218
^^^^^^^
216219

astroquery/utils/tap/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,8 @@ def upload_table(self, *, upload_resource=None, table_name=None,
14251425
raise ValueError("Missing mandatory argument 'upload_resource'")
14261426
if table_name is None:
14271427
raise ValueError("Missing mandatory argument 'table_name'")
1428+
if "." in table_name:
1429+
raise ValueError(f"Table name is not allowed to contain a dot: {table_name}")
14281430
if table_description is None:
14291431
description = ""
14301432
else:

astroquery/utils/tap/tests/test_tap.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
2828
from astroquery.utils.tap.core import TapPlus
2929
from astroquery.utils.tap import taputils
30+
from astropy.table import Table
3031

3132

3233
def read_file(filename):
@@ -936,3 +937,17 @@ def test_logout(mock_logout):
936937
with pytest.raises(HTTPError):
937938
tap.logout()
938939
assert (mock_logout.call_count == 2)
940+
941+
942+
def test_upload_table():
943+
conn_handler = DummyConnHandler()
944+
tap = TapPlus(url="http://test:1111/tap", connhandler=conn_handler)
945+
a = [1, 2, 3]
946+
b = ['a', 'b', 'c']
947+
table = Table([a, b], names=['col1', 'col2'], meta={'meta': 'first table'})
948+
949+
table_name = 'hola.table_test_from_astropy'
950+
with pytest.raises(ValueError) as exc_info:
951+
tap.upload_table(upload_resource=table, table_name=table_name)
952+
953+
assert str(exc_info.value) == f"Table name is not allowed to contain a dot: {table_name}"

0 commit comments

Comments
 (0)