|
1 | 1 | import logging
|
2 | 2 | from datetime import timedelta
|
3 |
| -from collections.abc import Iterator |
4 | 3 |
|
5 | 4 | import pytest
|
6 | 5 | from databricks.labs.blueprint.tui import MockPrompts
|
|
17 | 16 | _SPARK_CONF = get_azure_spark_conf()
|
18 | 17 |
|
19 | 18 |
|
20 |
| -@pytest.fixture |
21 |
| -def catalog_name(ws, make_random) -> Iterator[str]: |
22 |
| - name = f"test-catalog-{make_random(5)}" |
23 |
| - yield name |
24 |
| - try: |
25 |
| - ws.catalogs.delete(name, force=True) |
26 |
| - logger.info(f"Deleted test catalog: {name}") |
27 |
| - except NotFound: |
28 |
| - pass |
29 |
| - |
30 |
| - |
31 | 19 | @retried(on=[NotFound], timeout=timedelta(minutes=2))
|
32 |
| -def test_create_ucx_catalog_creates_catalog( |
33 |
| - ws, |
34 |
| - runtime_ctx, |
35 |
| - watchdog_remove_after, |
36 |
| - catalog_name, |
37 |
| -) -> None: |
38 |
| - prompts = MockPrompts({f"Please provide storage location url for catalog: {catalog_name}": "metastore"}) |
39 |
| - runtime_ctx.catalog_schema._ucx_catalog = catalog_name |
| 20 | +def test_create_ucx_catalog_creates_catalog(ws, runtime_ctx, watchdog_remove_after) -> None: |
| 21 | + # Delete catalog created for testing to test the creation of a new catalog |
| 22 | + runtime_ctx.workspace_client.catalogs.delete(runtime_ctx.ucx_catalog, force=True) |
| 23 | + prompts = MockPrompts({f"Please provide storage location url for catalog: {runtime_ctx.ucx_catalog}": "metastore"}) |
40 | 24 |
|
41 | 25 | runtime_ctx.catalog_schema.create_ucx_catalog(prompts, properties={"RemoveAfter": watchdog_remove_after})
|
42 | 26 |
|
43 |
| - @retried(on=[KeyError], timeout=timedelta(seconds=20)) |
| 27 | + @retried(on=[NotFound], timeout=timedelta(seconds=20)) |
44 | 28 | def get_catalog(name: str) -> CatalogInfo:
|
45 | 29 | return ws.catalogs.get(name)
|
46 | 30 |
|
47 |
| - assert get_catalog(catalog_name) |
| 31 | + assert get_catalog(runtime_ctx.ucx_catalog) |
48 | 32 |
|
49 | 33 |
|
50 | 34 | @retried(on=[NotFound], timeout=timedelta(minutes=2))
|
|
0 commit comments