test_download.py 1.2 KB

123456789101112131415161718192021222324
  1. import pytest
  2. from facefusion.download import conditional_download, get_download_size, is_download_done
  3. from .helper import get_test_example_file, get_test_examples_directory
  4. @pytest.fixture(scope = 'module', autouse = True)
  5. def before_all() -> None:
  6. conditional_download(get_test_examples_directory(),
  7. [
  8. 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
  9. ])
  10. def test_get_download_size() -> None:
  11. assert get_download_size('https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4') == 191675
  12. assert get_download_size('https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-360p.mp4') == 370732
  13. assert get_download_size('invalid') == 0
  14. def test_is_download_done() -> None:
  15. assert is_download_done('https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4', get_test_example_file('target-240p.mp4')) is True
  16. assert is_download_done('https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4', 'invalid') is False
  17. assert is_download_done('invalid', 'invalid') is False