databrickslabs / lsql

Lightweight SQL execution wrapper only on top of Databricks SDK
https://pypi.org/project/databricks-labs-lsql/
Other
8 stars 3 forks source link

[TECH DEBT] Replace the `make_dashboard` integration test fixture with `make_directory` #218

Open JCZuurmond opened 2 months ago

JCZuurmond commented 2 months ago

Instead of creating an empty, unpublished dashboard in the integration test to overwrite later. A temporary remote directory can be passed as parent path to the deploy dashboard:

  1. Overwriting an empy, unpublished dashboard is a bit of hack
  2. The remote directory can get a purge suffix so that it will be deleted by watch dog in case it is not cleaned up properly

Copy from ucx:

@pytest.fixture
def make_directory(ws, make_random):
    def create(*, path: str | None = None):
        if path is None:
            path = f"/Users/{ws.current_user.me().user_name}/lsql-{make_random(4)}-{get_purge_suffix()}"
        ws.workspace.mkdirs(path)
        return path

    yield from factory("directory", create, lambda x: ws.workspace.delete(x, recursive=True))