Files
kumain-inandHarry bf33010fe5 test: make three path assertions hold on Windows
Three tests fail on Windows although the code they cover works there:

- test_material.py::test_metadata_probe_failure_preserves_existing_cache
  expects _validate_video(str(cached_path)), but save_video() builds the
  path as f"{save_dir}/{video_id}.mp4", so on Windows the call carries a
  forward slash where str(Path) has a backslash. Compare the argument as
  a Path.
- test_utils_ffmpeg_check.py::test_normalizes_home_path_in_os_environ and
  ::test_encode_with_tilde_path set only HOME, but os.path.expanduser()
  reads USERPROFILE on Windows (HOME is ignored since Python 3.8), so "~"
  still expanded to the real profile: the first assertion failed and the
  MoviePy encode raised FileNotFoundError. Set USERPROFILE as well, and
  compare normalised paths, because ntpath.expanduser() keeps the "/" of
  "~/bin/ffmpeg".

POSIX runs are unaffected: posixpath.expanduser() ignores USERPROFILE and
normpath() leaves an already normal path alone. Neither file is in the
windows-smoke job, so CI did not see these failures.
2026-11-07 08:16:12 +08:00
..
2025-05-10 12:34:37 +08:00
2026-07-13 18:08:07 +08:00

MoneyPrinterTurbo Test Directory

This directory contains unit tests for the MoneyPrinterTurbo project.

Directory Structure

  • services/: Domain-focused unit and controller tests
    • test_task.py: Task pipeline tests
    • test_task_manager.py: In-memory and Redis queue tests
    • test_controller_*.py: API controller tests split by controller domain
    • test_video.py, test_voice.py: Media service tests
  • test_main.py: Application entry-point test

Running Tests

The CI suite uses pytest, which also runs the existing unittest.TestCase tests:

# Run all tests
uv run python -X utf8 -m pytest -q test

# Run a specific test file
uv run python -X utf8 -m pytest -q test/services/test_video.py

# Run a specific test class
uv run python -X utf8 -m pytest -q test/services/test_video.py::TestVideoService

# Run a specific test method
uv run python -X utf8 -m pytest -q test/services/test_video.py::TestVideoService::test_preprocess_video

To run the same branch coverage check used by CI:

uv run python -X utf8 -m coverage run -m pytest -q test
uv run python -m coverage report

Live provider tests are skipped by default. To run tests that may call external TTS or LLM services, set MPT_RUN_INTEGRATION_TESTS=1 and provide the required provider credentials.

Adding New Tests

To add tests for other components, follow these guidelines:

  1. Name files test_<domain>.py and keep each file focused on one domain.
  2. Split broad controller suites into files such as test_controller_video.py.
  3. Use either pytest functions or unittest.TestCase; pytest collects both.
  4. Name test functions and methods with the test_ prefix.

Test Resources

Place any resource files required for testing in the test/resources directory.