Skip to content

add test suite#263

Open
palakpsheth wants to merge 12 commits intoMcCloudS:mainfrom
palakpsheth:main
Open

add test suite#263
palakpsheth wants to merge 12 commits intoMcCloudS:mainfrom
palakpsheth:main

Conversation

@palakpsheth
Copy link
Copy Markdown
Contributor

@palakpsheth palakpsheth commented Jan 11, 2026

Overview

This PR adds a full pytest-based unit test suite for subgen.py and wires up CI to run those tests with coverage. The tests are designed to maximize coverage while avoiding heavy runtime dependencies by using lightweight stubs for external libraries (FastAPI, stable-whisper, ffmpeg/av, requests, watchdog, torch).

Key changes

  • Added tests/conftest.py with dependency stubs + a subgen_module fixture that:
    • disables background threads (CONCURRENT_TRANSCRIPTIONS=0) and filesystem monitor
    • injects stub modules to avoid importing GPU/FFmpeg/HTTP dependencies
    • keeps import side effects deterministic and fast
  • Added tests/test_subgen.py with broad coverage for:
    • env helpers (convert_to_bool, get_env_with_fallback)
    • queueing logic (DeduplicatedQueue)
    • webhook handlers (Tautulli/Plex/Jellyfin/Emby) with path mapping
    • ASR + detect-language handlers
    • subtitle naming, skip logic, and language selection
    • audio/subtitle helpers (track parsing, subtitle discovery, audio extraction)
    • miscellaneous helpers (path mapping, file stability, has_audio, etc.)
  • Added pytest.ini to ensure repo root is on PYTHONPATH
  • Added .github/workflows/tests.yml to run pytest on push/PR and upload coverage.xml
  • Updated .gitignore to keep __pycache__, *.pyc, and coverage artifacts out of git

Testing

  • pytest -q --cov=subgen --cov-report=term-missing --cov-report=xml

Coverage

  • CI uploads coverage.xml as an artifact.
  • Coverage focuses on subgen.py execution paths; external dependencies are stubbed, so this does not validate real FFmpeg/AV/Whisper integrations.

Notes / limitations

  • The tests are intentionally unit-level and avoid network access or real media processing.
  • Integration behavior with real media files, FFmpeg/AV, and Whisper models is not covered here.

palakpsheth and others added 12 commits January 10, 2026 16:13
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: palakpsheth <13122115+palakpsheth@users.noreply.github.com>
Co-authored-by: palakpsheth <13122115+palakpsheth@users.noreply.github.com>
[WIP] Add subgen test suite and CI workflow
…ilot/sub-pr-1-again

# Conflicts:
#	.gitignore
Apply review feedback: fix fixture ordering and remove unused import
Add subgen test suite and CI workflow
Copilot AI review requested due to automatic review settings January 11, 2026 00:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a comprehensive test suite for the subgen project using pytest. The test suite includes 57 test cases covering various functionality of the subtitle generation system, from webhook handling to audio processing and file operations.

Changes:

  • Added comprehensive pytest-based test suite with 57 test cases
  • Implemented GitHub Actions CI workflow for automated testing
  • Added pytest configuration and updated .gitignore for test artifacts

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_subgen.py Implements 57 test cases covering core functionality including webhooks, audio processing, subtitle generation, and file operations
tests/conftest.py Provides pytest fixture that stubs all heavy dependencies (fastapi, stable-whisper, ffmpeg, etc.) allowing tests to run with minimal dependencies
pytest.ini Configures pytest with pythonpath to enable imports from project root
.gitignore Adds Python test artifacts (pycache, .coverage, coverage.xml, htmlcov/)
.github/workflows/tests.yml Sets up CI pipeline with Python 3.11, runs pytest with coverage reporting, and uploads coverage artifacts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants