Skip to content

Commit a63e5be

Browse files
committed
small fixes
1 parent 33ba180 commit a63e5be

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/databricks/labs/pytester/fixtures/catalog.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,21 +497,19 @@ def create(
497497
schema_name = schema.name
498498

499499
if not name:
500-
name = f"dummy_vol_{make_random(6).lower()}"
500+
name = f"dummy_v{make_random(6).lower()}"
501501

502502
volume_info = ws.volumes.create(
503503
catalog_name=catalog_name,
504504
schema_name=schema_name,
505505
name=name,
506506
volume_type=VolumeType.MANAGED,
507507
)
508-
if isinstance(volume_info, Mock):
509-
volume_info.name = name
510508
path = f'explore/data/{volume_info.catalog_name}/{volume_info.schema_name}/{volume_info.name}'
511509
log_workspace_link(f'{volume_info.name} volume', path)
512510
return volume_info
513511

514512
def remove(volume_info: VolumeInfo):
515-
ws.volumes.delete(f"{volume_info.catalog_name}.{volume_info.schema_name}.{volume_info.name}", force=True)
513+
ws.volumes.delete(f"{volume_info.catalog_name}.{volume_info.schema_name}.{volume_info.name}")
516514

517515
yield from factory("volume", create, remove)

tests/unit/fixtures/test_catalog.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest.mock import ANY
22

3-
from databricks.sdk.service.catalog import TableInfo, TableType, DataSourceFormat, FunctionInfo, SchemaInfo
3+
from databricks.sdk.service.catalog import TableInfo, TableType, DataSourceFormat, FunctionInfo, SchemaInfo, VolumeType, VolumeInfo
44

55
from databricks.labs.pytester.fixtures.unwrap import call_stateful
66
from databricks.labs.pytester.fixtures.catalog import (
@@ -160,21 +160,18 @@ def test_make_schema() -> None:
160160
)
161161

162162

163-
def test_make_volume():
163+
def test_make_volume_noargs():
164164
ctx, info = call_stateful(make_volume)
165-
166165
ctx['ws'].volumes.create.assert_called_once()
167-
print(info)
168-
assert info.catalog_name is not None
169-
assert info.schema_name is not None
170-
assert info.name is not None
166+
assert info is not None
171167

172168

173169
def test_make_volume_with_name():
174170
ctx, info = call_stateful(make_volume, name='test_volume')
175-
176-
ctx['ws'].volumes.create.assert_called_once()
177-
assert info.catalog_name is not None
178-
assert info.schema_name is not None
179-
assert info.name == 'test_volume'
180-
171+
ctx['ws'].volumes.create.assert_called_once_with(
172+
name='test_volume',
173+
catalog_name="dummy_crandom",
174+
schema_name="dummy_srandom",
175+
volume_type=VolumeType.MANAGED
176+
)
177+
assert info is not None

0 commit comments

Comments
 (0)