Skip to content

Commit c434cad

Browse files
InfantLabclaude
andcommitted
test: fix pre-existing storage and audio diarization test failures
These tests failed on the published master independently of the install fix; clearing them so CI can go green. - delete_job now returns bool (True if deleted, False if not found) on the StorageBackend ABC and the file and sqlite backends, matching test expectations and giving callers a not-found signal. - update two stale diarization test assertions from the removed pyannote use_auth_token= kwarg to the current token= kwarg (the pipeline already uses token=). - mock PyAnnotePipeline.from_pretrained in the two modular-registration tests so they no longer attempt a real gated-model download. Full suite: 1026 passed, 24 skipped, coverage 57.66%. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 12f3cc9 commit c434cad

6 files changed

Lines changed: 43 additions & 12 deletions

File tree

src/videoannotator/storage/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,14 @@ def list_jobs(self, status_filter: str | None = None) -> list[str]:
9494
pass
9595

9696
@abstractmethod
97-
def delete_job(self, job_id: str) -> None:
97+
def delete_job(self, job_id: str) -> bool:
9898
"""Delete all data for a job.
9999
100100
Args:
101101
job_id: Unique job identifier
102+
103+
Returns:
104+
True if the job existed and was deleted, False if it was not found.
102105
"""
103106
pass
104107

src/videoannotator/storage/file_backend.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,24 @@ def get_all_jobs(self, status_filter: str | None = None) -> list[BatchJob]:
198198

199199
return sorted(jobs, key=lambda j: j.created_at)
200200

201-
def delete_job(self, job_id: str) -> None:
202-
"""Delete all data for a job."""
201+
def delete_job(self, job_id: str) -> bool:
202+
"""Delete all data for a job.
203+
204+
Returns:
205+
True if the job existed and was deleted, False if it was not found.
206+
"""
203207
job_dir = self._get_job_dir(job_id)
204208

205209
if job_dir.exists():
206210
import shutil
207211

208212
shutil.rmtree(job_dir)
209213
self.logger.info(f"Deleted job {job_id}")
210-
else:
211-
self.logger.warning(f"Job {job_id} not found for deletion")
212-
self.logger.warning(f"Job directory not found: {job_dir}")
214+
return True
215+
216+
self.logger.warning(f"Job {job_id} not found for deletion")
217+
self.logger.warning(f"Job directory not found: {job_dir}")
218+
return False
213219

214220
def get_stats(self) -> dict[str, Any]:
215221
"""Get storage statistics."""

src/videoannotator/storage/sqlite_backend.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,12 @@ def list_jobs(self, status_filter: str | None = None) -> list[str]:
363363
self.logger.error(f"[ERROR] Failed to list jobs: {e}")
364364
return []
365365

366-
def delete_job(self, job_id: str) -> None:
367-
"""Delete all data for a job including persistent storage."""
366+
def delete_job(self, job_id: str) -> bool:
367+
"""Delete all data for a job including persistent storage.
368+
369+
Returns:
370+
True if the job existed and was deleted, False if it was not found.
371+
"""
368372
import shutil
369373

370374
from ..storage.config import get_job_storage_path
@@ -397,6 +401,8 @@ def delete_job(self, job_id: str) -> None:
397401
f"[WARNING] Failed to delete storage for job {job_id}: {storage_error}"
398402
)
399403

404+
return deleted_count > 0
405+
400406
except SQLAlchemyError as e:
401407
self.logger.error(f"[ERROR] Failed to delete job {job_id}: {e}")
402408
raise

tests/pipelines/test_audio_individual_components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_diarization_pipeline_initialize_success(self, mock_pyannote):
8888
or os.environ.get("HUGGINGFACE_TOKEN")
8989
or "FAKE_TOKEN_FOR_TESTING"
9090
)
91-
assert called_kwargs["use_auth_token"] == expected_token
91+
assert called_kwargs["token"] == expected_token
9292

9393
pipeline.cleanup()
9494

tests/pipelines/test_audio_pipeline.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ def test_audio_pipeline_default_config(self):
4747
assert pipeline.config["pipelines"]["speech_recognition"]["enabled"]
4848
assert pipeline.config["pipelines"]["speaker_diarization"]["enabled"]
4949

50-
def test_modular_pipeline_initialization(self):
50+
@patch(
51+
"videoannotator.pipelines.audio_processing.diarization_pipeline.PYANNOTE_AVAILABLE",
52+
True,
53+
)
54+
@patch(
55+
"videoannotator.pipelines.audio_processing.diarization_pipeline.PyAnnotePipeline"
56+
)
57+
def test_modular_pipeline_initialization(self, mock_pyannote):
5158
"""Test that modular pipeline components are properly initialized."""
59+
mock_pyannote.from_pretrained.return_value = Mock()
5260
config = {
5361
"pipelines": {
5462
"speech_recognition": {"enabled": True, "model": "base"},
@@ -121,8 +129,16 @@ def test_speech_recognition_component(self, mock_whisper, temp_audio_file):
121129
except Exception as e:
122130
pytest.skip(f"Speech recognition test failed: {e}")
123131

124-
def test_speaker_diarization_component(self, temp_audio_file):
132+
@patch(
133+
"videoannotator.pipelines.audio_processing.diarization_pipeline.PYANNOTE_AVAILABLE",
134+
True,
135+
)
136+
@patch(
137+
"videoannotator.pipelines.audio_processing.diarization_pipeline.PyAnnotePipeline"
138+
)
139+
def test_speaker_diarization_component(self, mock_pyannote, temp_audio_file):
125140
"""Test speaker diarization component within modular pipeline."""
141+
mock_pyannote.from_pretrained.return_value = Mock()
126142
config = {
127143
"pipelines": {
128144
"speech_recognition": {

tests/pipelines/test_audio_speech_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_diarization_pipeline_initialize_success(self, mock_pyannote):
9696
# Check that model was loaded with correct parameters
9797
mock_pyannote.from_pretrained.assert_called_once_with(
9898
"pyannote/speaker-diarization-3.1",
99-
use_auth_token="FAKE_TOKEN_FOR_TESTING",
99+
token="FAKE_TOKEN_FOR_TESTING",
100100
)
101101

102102
pipeline.cleanup()

0 commit comments

Comments
 (0)