This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
flamenco-worker/tests/test_commands_remove_file.py
Sybren A. Stüvel 6477e908d1 Added support for commands used in the blender-video-chunks job type
Adds the following commands:

    - blender_render_audio
    - concat_videos
    - create_video
    - move_with_counter
    - mux_audio
2018-12-07 11:25:07 +01:00

61 lines
1.7 KiB
Python

from pathlib import Path
from tests.test_runner import AbstractCommandTest
class RemoveFileTest(AbstractCommandTest):
def setUp(self):
super().setUp()
from flamenco_worker.commands import RemoveFileCommand
import tempfile
self.tmpdir = tempfile.TemporaryDirectory()
self.tmppath = Path(self.tmpdir.name)
self.cmd = RemoveFileCommand(
worker=self.fworker,
task_id='12345',
command_idx=0,
)
def tearDown(self):
super().tearDown()
self.tmpdir.cleanup()
def test_validate_settings(self):
self.assertIn('path', self.cmd.validate({'path': 12}))
self.assertIn('path', self.cmd.validate({'path': ''}))
self.assertIn('path', self.cmd.validate({}))
self.assertFalse(self.cmd.validate({'path': '/some/path'}))
def test_nonexistant_source(self):
path = self.tmppath / 'nonexisting'
task = self.cmd.run({'path': str(path)})
ok = self.loop.run_until_complete(task)
self.assertTrue(ok)
self.assertFalse(path.exists())
def test_source_file(self):
path = self.tmppath / 'existing'
path.touch()
task = self.cmd.run({'path': str(path)})
ok = self.loop.run_until_complete(task)
self.assertTrue(ok)
self.assertFalse(path.exists())
def test_soure_dir_with_files(self):
path = self.tmppath / 'dir'
path.mkdir()
(path / 'a.file').touch()
(path / 'b.file').touch()
(path / 'c.file').touch()
task = self.cmd.run({'path': str(path)})
ok = self.loop.run_until_complete(task)
self.assertFalse(ok)
self.assertTrue(path.exists())