Skip to content

Add pytest coverage for video_processing, detection, and classification modules - #19

Merged
tkswanson merged 7 commits into
mainfrom
copilot/add-tests-for-video-detection-classification
Aug 20, 2026
Merged

Add pytest coverage for video_processing, detection, and classification modules#19
tkswanson merged 7 commits into
mainfrom
copilot/add-tests-for-video-detection-classification

Conversation

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown

Adds missing test coverage for the three core inference modules (video_processing, detection, classification), following the existing pytest structure and conftest stub pattern.

New test files

  • tests/test_video_processing.pyget_images, get_videos, extract_frames (error cases, image-only, mixed, file output), _count_frames (missing file, frame list shape, fps mode)
  • tests/test_detection.pyload_detector (missing file, model type), parse_detections (columns, empty detections, threshold filtering, manifest merge, error cases, file output), get_animals/get_empty (label + category int fallback), _convert_detections (no-detection path)
  • tests/test_classification.pyload_classifier (with/without classes arg), load_class_list, classify (DataFrame/string/list inputs, missing column, file output, invalid input), single_classification (prediction column, empties, best=True, empty animals)

conftest.py

Extended _install_optional_stubs() to stub cv2 when OpenCV is not installed, consistent with existing onnxruntime and exiftool stubs. The _FakeCapture returns 30 frames at 10 FPS so video extraction tests run without real video files.

# Example: video extraction works with stub cv2 and a zero-byte placeholder
def test_extract_frames_includes_videos(video_manifest):
    result = extract_frames(video_manifest, frames=3, parallel=False)
    assert "frame" in result.columns and len(result) >= 1

Copilot AI and others added 2 commits August 20, 2026 20:30
Co-authored-by: tkswanson <4371698+tkswanson@users.noreply.github.com>
…omments

Co-authored-by: tkswanson <4371698+tkswanson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for video detection and classification Add pytest coverage for video_processing, detection, and classification modules Aug 20, 2026
Copilot AI requested a review from tkswanson August 20, 2026 20:31
…video files

- Replace invalid assertions that expect non-None for fake files
- Add tests expecting None for corrupted/invalid video files
- Add comprehensive mocked tests for valid video processing
- Test both frames and fps parameters
- Verify frame indices are within valid bounds
- Test edge cases (zero frames, fps detection failure)
@tkswanson
tkswanson marked this pull request as ready for review August 20, 2026 22:13
@tkswanson
tkswanson merged commit 3b8f402 into main Aug 20, 2026
2 checks passed
@tkswanson
tkswanson deleted the copilot/add-tests-for-video-detection-classification branch August 20, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add tests for video, detection, classification

2 participants