Skip to content

Commit 26be0f2

Browse files
committed
Test fix
1 parent c2a2abf commit 26be0f2

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

‎tests/model_loader_test.py‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,35 @@ def test_whisper_model_removes_file(self, tmp_path):
543543
model.delete_local_file()
544544
assert not model_file.exists()
545545

546-
def test_whisper_cpp_custom_removes_file(self, tmp_path):
546+
def test_whisper_cpp_custom_removes_file_owned_by_buzz(self, tmp_path):
547547
model_file = tmp_path / "ggml-model-whisper-custom.bin"
548548
model_file.write_bytes(b"fake model data")
549549
model = TranscriptionModel(model_type=ModelType.WHISPER_CPP, whisper_model_size=WhisperModelSize.CUSTOM)
550-
with patch.object(model, 'get_local_model_path', return_value=str(model_file)):
550+
with patch("buzz.model_loader.model_root_dir", str(tmp_path)), \
551+
patch.object(model, 'get_local_model_path', return_value=str(model_file)):
551552
model.delete_local_file()
552553
assert not model_file.exists()
553554

555+
def test_whisper_cpp_custom_keeps_file_outside_model_root(self, tmp_path):
556+
model_root = tmp_path / "models"
557+
model_root.mkdir()
558+
user_dir = tmp_path / "elsewhere"
559+
user_dir.mkdir()
560+
model_file = user_dir / "my-own-model.bin"
561+
model_file.write_bytes(b"fake model data")
562+
model = TranscriptionModel(
563+
model_type=ModelType.WHISPER_CPP,
564+
whisper_model_size=WhisperModelSize.CUSTOM,
565+
custom_model_id="my-own-model",
566+
)
567+
with patch("buzz.model_loader.model_root_dir", str(model_root)), \
568+
patch("buzz.settings.whisper_cpp_custom_models.remove_custom_model") as mock_remove, \
569+
patch.object(model, 'get_local_model_path', return_value=str(model_file)):
570+
model.delete_local_file()
571+
# The user's own file is left in place, only the registry entry is removed
572+
assert model_file.exists()
573+
mock_remove.assert_called_once_with("my-own-model")
574+
554575
def test_whisper_cpp_non_custom_removes_bin_file(self, tmp_path):
555576
model_file = tmp_path / "ggml-tiny.bin"
556577
model_file.write_bytes(b"fake model data")

0 commit comments

Comments
 (0)