test_temp_helper.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import os.path
  2. import tempfile
  3. import pytest
  4. from facefusion import state_manager
  5. from facefusion.download import conditional_download
  6. from facefusion.temp_helper import get_temp_directory_path, get_temp_file_path, get_temp_frames_pattern
  7. from .helper import get_test_example_file, get_test_examples_directory
  8. @pytest.fixture(scope = 'module', autouse = True)
  9. def before_all() -> None:
  10. conditional_download(get_test_examples_directory(),
  11. [
  12. 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
  13. ])
  14. state_manager.init_item('temp_frame_format', 'png')
  15. def test_get_temp_file_path() -> None:
  16. temp_directory = tempfile.gettempdir()
  17. assert get_temp_file_path(get_test_example_file('target-240p.mp4')) == os.path.join(temp_directory, 'facefusion', 'target-240p', 'temp.mp4')
  18. def test_get_temp_directory_path() -> None:
  19. temp_directory = tempfile.gettempdir()
  20. assert get_temp_directory_path(get_test_example_file('target-240p.mp4')) == os.path.join(temp_directory, 'facefusion', 'target-240p')
  21. def test_get_temp_frames_pattern() -> None:
  22. temp_directory = tempfile.gettempdir()
  23. assert get_temp_frames_pattern(get_test_example_file('target-240p.mp4'), '%04d') == os.path.join(temp_directory, 'facefusion', 'target-240p', '%04d.png')