|
17 | 17 | import os |
18 | 18 | from unittest.mock import MagicMock |
19 | 19 |
|
| 20 | +import pytest |
20 | 21 | from google.api_core.exceptions import NotFound |
21 | 22 | from google.cloud.bigquery import Dataset, DatasetReference, Table, TableReference |
22 | 23 | from google.cloud.bigquery.external_config import ExternalCatalogDatasetOptions, ExternalCatalogTableOptions |
23 | 24 | from pytest_mock import MockFixture |
24 | 25 |
|
25 | 26 | from pyiceberg.catalog.bigquery_metastore import ICEBERG_TABLE_TYPE_VALUE, TABLE_TYPE_PROP, BigQueryMetastoreCatalog |
26 | | -from pyiceberg.exceptions import NoSuchTableError |
| 27 | +from pyiceberg.exceptions import NoSuchNamespaceError, NoSuchTableError |
27 | 28 | from pyiceberg.schema import Schema |
28 | 29 |
|
29 | 30 |
|
@@ -178,3 +179,15 @@ def test_list_namespaces(mocker: MockFixture) -> None: |
178 | 179 | assert ("dataset1",) in namespaces |
179 | 180 | assert ("dataset2",) in namespaces |
180 | 181 | client_mock.list_datasets.assert_called_once() |
| 182 | + |
| 183 | + |
| 184 | +def test_load_namespace_properties_rejects_multipart_namespace(mocker: MockFixture) -> None: |
| 185 | + client_mock = MagicMock() |
| 186 | + mocker.patch("pyiceberg.catalog.bigquery_metastore.Client", return_value=client_mock) |
| 187 | + mocker.patch.dict(os.environ, values={"PYICEBERG_LEGACY_CURRENT_SNAPSHOT_ID": "True"}) |
| 188 | + catalog = BigQueryMetastoreCatalog("test_catalog", **{"gcp.bigquery.project-id": "my-project"}) |
| 189 | + |
| 190 | + with pytest.raises(NoSuchNamespaceError, match="hierarchical namespaces are not supported"): |
| 191 | + catalog.load_namespace_properties(("dataset", "table")) |
| 192 | + |
| 193 | + client_mock.get_dataset.assert_not_called() |
0 commit comments