Skip to content

Commit b736965

Browse files
test: update Switch installation tests for refactored interface
Update test_installation.py to match the refactored SwitchDeployment.install() interface that now takes only resources parameter (path resolution is internal). Changes: - Remove switch_repository fixture parameter from test methods - Delete unused _StubTranspilerRepository stub class - Remove unused imports (Path, TranspilerRepository) - Update assertions to check only resources argument The tests verify that: 1. Switch installation uses configured resources correctly 2. Missing resources logs appropriate error message
1 parent 2ee157f commit b736965

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

tests/unit/deployment/test_installation.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
from pathlib import Path
32
from unittest.mock import create_autospec
43

54
import pytest
@@ -23,7 +22,6 @@
2322
from databricks.labs.lakebridge.deployment.installation import WorkspaceInstallation
2423
from databricks.labs.lakebridge.deployment.recon import ReconDeployment
2524
from databricks.labs.lakebridge.deployment.switch import SwitchDeployment
26-
from databricks.labs.lakebridge.transpiler.repository import TranspilerRepository
2725

2826

2927
@pytest.fixture
@@ -249,28 +247,7 @@ def test_uninstall_configs_missing(ws):
249247
class TestSwitchInstallation:
250248
"""Tests for Switch transpiler installation."""
251249

252-
class _StubTranspilerRepository:
253-
def __init__(self, names: set[str], base_path: Path):
254-
self._names = names
255-
self._base_path = base_path
256-
257-
def all_transpiler_names(self) -> set[str]:
258-
return self._names
259-
260-
def transpilers_path(self) -> Path:
261-
return self._base_path
262-
263-
@pytest.fixture
264-
def switch_repository(self, monkeypatch, tmp_path) -> "_StubTranspilerRepository":
265-
repository = self._StubTranspilerRepository({"switch"}, tmp_path / "repository")
266-
267-
def _user_home(_: type[TranspilerRepository]) -> "TestSwitchInstallation._StubTranspilerRepository":
268-
return repository
269-
270-
monkeypatch.setattr(TranspilerRepository, "user_home", classmethod(_user_home))
271-
return repository
272-
273-
def test_switch_install_uses_configured_resources(self, ws, switch_repository):
250+
def test_switch_install_uses_configured_resources(self, ws):
274251
prompts = MockPrompts({})
275252
recon_deployment = create_autospec(ReconDeployment)
276253
switch_deployment = create_autospec(SwitchDeployment)
@@ -292,11 +269,10 @@ def test_switch_install_uses_configured_resources(self, ws, switch_repository):
292269
ws_installation.install(config)
293270

294271
switch_deployment.install.assert_called_once()
295-
args, _kwargs = switch_deployment.install.call_args
296-
assert isinstance(args[0], Path)
297-
assert args[1] is switch_resources
272+
args, _ = switch_deployment.install.call_args
273+
assert args[0] is switch_resources
298274

299-
def test_switch_install_missing_resources_logs_error(self, ws, switch_repository, caplog):
275+
def test_switch_install_missing_resources_logs_error(self, ws, caplog):
300276
prompts = MockPrompts({})
301277
recon_deployment = create_autospec(ReconDeployment)
302278
switch_deployment = create_autospec(SwitchDeployment)

0 commit comments

Comments
 (0)