Skip to content

Commit 9f0cfe3

Browse files
fix: create test directories before safety validation
- test_workspace_in_temp_dir_allowed: create/cleanup temp dir - test_is_safe_workspace: use existing temp dir pattern
1 parent 75288b5 commit 9f0cfe3

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

tests/unit/video/test_backend_safety.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ def test_unsafe_workspace_outside_base_dir(self):
4444
def test_workspace_in_temp_dir_allowed(self):
4545
"""Test workspace in temp directory is allowed."""
4646
import tempfile
47-
temp_workspace = Path(tempfile.gettempdir()) / "test_workspace"
48-
49-
assert self.backend._is_safe_workspace(temp_workspace)
47+
temp_workspace = Path(tempfile.gettempdir()) / "test_workspace_mg"
48+
temp_workspace.mkdir(exist_ok=True)
49+
try:
50+
assert self.backend._is_safe_workspace(temp_workspace)
51+
finally:
52+
temp_workspace.rmdir()
5053

5154
def test_nonexistent_workspace_rejected(self):
5255
"""Test non-existent workspace is rejected."""

tests/unit/video/test_html_backend.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,15 @@ async def test_render_unsafe_workspace(self):
229229

230230
def test_is_safe_workspace(self):
231231
"""Test workspace safety validation."""
232-
# Valid workspace
233-
valid_workspace = Path("/tmp/test_workspace")
234-
assert self.backend._is_safe_workspace(valid_workspace) is True
235-
236232
# Test with actual path that exists
237233
with tempfile.TemporaryDirectory() as tmpdir:
238234
workspace = Path(tmpdir)
239235
assert self.backend._is_safe_workspace(workspace) is True
236+
237+
# Test with subdirectory that exists
238+
sub_workspace = Path(tmpdir) / "test_workspace"
239+
sub_workspace.mkdir()
240+
assert self.backend._is_safe_workspace(sub_workspace) is True
240241

241242
def test_get_crf_for_quality(self):
242243
"""Test CRF value mapping for quality settings."""

0 commit comments

Comments
 (0)