mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-11-14 18:22:59 +01:00
Reviewer's live API test surfaced that PATCH /videos/:id/stats/downloads returns 404 against real Coverr Demo keys, so the 'compliance ping' this PR originally added was silently failing on every download. Re-reading the official docs (https://api.coverr.co/docs/videos/#download-a-video) clarifies why: Coverr exposes two distinct download paths. - urls.mp4 is the hotlink URL, used when an app first lets a user PREVIEW the video and later commits to it; in that case the partner must PATCH /videos/:id/stats/downloads to register the download event. - urls.mp4_download is the direct-download URL; GETting it is itself the registered download event (response includes Content-Disposition: attachment), and the docs explicitly say 'no additional action is required'. This PR's pipeline always wants the direct download path (search -> download to disk -> ffmpeg concat -> output MP4), so it should have been using urls.mp4_download from the start. The PATCH ping was both the wrong call for the wrong URL. Changes: - search_videos_coverr now reads urls.mp4_download and assigns it directly to MaterialInfo.url - Drop the COVERR_URL_PREFIX 'coverr://<id>|<mp4_url>' encoding scheme; coverr items are now plain URLs like pexels/pixabay - Delete _ping_coverr_download() entirely - Drop the coverr-specific branch in download_videos(); coverr now flows through the exact same code path as pexels/pixabay - Tests: drop the two _ping_coverr_download tests and the two download_videos coverr-branch tests; replace with one focused test that verifies coverr items pass their mp4_download URL unchanged to save_video; update existing search tests to use urls.mp4_download in both mock responses and assertions Verified locally: uv run python -m unittest test.services.test_material test.services.test_webui_i18n -> Ran 15 tests in 0.023s, OK uv run --with pytest pytest test/services/test_material.py test/services/test_webui_i18n.py test/services/test_video.py -q -> 39 passed, 2 subtests passed in 3.03s
MoneyPrinterTurbo Test Directory
This directory contains unit tests for the MoneyPrinterTurbo project.
Directory Structure
services/: Tests for components in theapp/servicesdirectorytest_video.py: Tests for the video servicetest_task.py: Tests for the task servicetest_voice.py: Tests for the voice service
Running Tests
You can run the tests using Python’s built-in unittest framework:
# Run all tests
python -m unittest discover -s test
# Run a specific test file
python -m unittest test/services/test_video.py
# Run a specific test class
python -m unittest test.services.test_video.TestVideoService
# Run a specific test method
python -m unittest test.services.test_video.TestVideoService.test_preprocess_video
Adding New Tests
To add tests for other components, follow these guidelines:
- Create test files prefixed with
test_in the appropriate subdirectory - Use
unittest.TestCaseas the base class for your test classes - Name test methods with the
test_prefix
Test Resources
Place any resource files required for testing in the test/resources directory.