diff --git a/CHANGES.rst b/CHANGES.rst index cf407a9582..1f2ab23ef3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,8 +12,11 @@ Service fixes and enhancements Infrastructure, Utility and Other Changes and Additions ------------------------------------------------------- +utils.tap +^^^^^^^^^ - +- ``TapPlus.upload_table`` should not allow table names to contain a + dot. ``ValueError`` is now raised for such cases. [#2971] 0.4.7 (2024-03-08) diff --git a/astroquery/utils/tap/core.py b/astroquery/utils/tap/core.py index ce0bd833a0..a598bd8630 100755 --- a/astroquery/utils/tap/core.py +++ b/astroquery/utils/tap/core.py @@ -1425,6 +1425,8 @@ def upload_table(self, *, upload_resource=None, table_name=None, raise ValueError("Missing mandatory argument 'upload_resource'") if table_name is None: raise ValueError("Missing mandatory argument 'table_name'") + if "." in table_name: + raise ValueError(f"Table name is not allowed to contain a dot: {table_name}") if table_description is None: description = "" else: diff --git a/astroquery/utils/tap/tests/test_tap.py b/astroquery/utils/tap/tests/test_tap.py index 47efa10c2c..507fb6ed98 100644 --- a/astroquery/utils/tap/tests/test_tap.py +++ b/astroquery/utils/tap/tests/test_tap.py @@ -27,6 +27,7 @@ from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse from astroquery.utils.tap.core import TapPlus from astroquery.utils.tap import taputils +from astropy.table import Table def read_file(filename): @@ -936,3 +937,17 @@ def test_logout(mock_logout): with pytest.raises(HTTPError): tap.logout() assert (mock_logout.call_count == 2) + + +def test_upload_table(): + conn_handler = DummyConnHandler() + tap = TapPlus(url="http://test:1111/tap", connhandler=conn_handler) + a = [1, 2, 3] + b = ['a', 'b', 'c'] + table = Table([a, b], names=['col1', 'col2'], meta={'meta': 'first table'}) + + table_name = 'hola.table_test_from_astropy' + with pytest.raises(ValueError) as exc_info: + tap.upload_table(upload_resource=table, table_name=table_name) + + assert str(exc_info.value) == f"Table name is not allowed to contain a dot: {table_name}"