fix: resolve 48 lint errors in test files
- Remove whitespace from 22 blank lines (W293) - Remove 6 unused imports (F401): os, Mock, MagicMock, Path - Add missing imports for 12 test functions (F821): sanitize_filename, extract_remote_path, MagicMock - Fix 1 unsorted import block (I001) All ruff checks now pass successfully. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -425,6 +425,8 @@ class TestSanitizeFilenameEdgeCases:
|
||||
|
||||
def test_handles_empty_string(self):
|
||||
"""Test with empty string."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
result = sanitize_filename("")
|
||||
# Should return a default document name
|
||||
assert "document_" in result
|
||||
@@ -432,23 +434,31 @@ class TestSanitizeFilenameEdgeCases:
|
||||
|
||||
def test_handles_only_periods(self):
|
||||
"""Test with only periods."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
result = sanitize_filename("...")
|
||||
# Should return a default document name
|
||||
assert "document_" in result
|
||||
|
||||
def test_handles_only_dots(self):
|
||||
"""Test with single dot."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
result = sanitize_filename(".")
|
||||
# Should return a default document name
|
||||
assert "document_" in result
|
||||
|
||||
def test_preserves_multiple_extensions(self):
|
||||
"""Test that multiple extensions are preserved."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
result = sanitize_filename("file.tar.gz")
|
||||
assert ".tar.gz" in result or "file_tar_gz" in result
|
||||
|
||||
def test_removes_null_bytes(self):
|
||||
"""Test that null bytes are removed."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
result = sanitize_filename("file\x00name.pdf")
|
||||
assert "\x00" not in result
|
||||
assert "file" in result
|
||||
@@ -456,6 +466,8 @@ class TestSanitizeFilenameEdgeCases:
|
||||
|
||||
def test_handles_unicode_characters(self):
|
||||
"""Test handling of unicode characters."""
|
||||
from app.utils.filename_utils import sanitize_filename
|
||||
|
||||
result = sanitize_filename("文档.pdf")
|
||||
# Should preserve unicode or convert safely
|
||||
assert ".pdf" in result
|
||||
@@ -468,31 +480,39 @@ class TestExtractRemotePathEdgeCases:
|
||||
|
||||
def test_file_not_in_base_dir(self):
|
||||
"""Test when file is not a subdirectory of base_dir."""
|
||||
from app.utils.filename_utils import extract_remote_path
|
||||
|
||||
result = extract_remote_path("/other/path/file.pdf", "/base/dir", "/remote")
|
||||
# Should just use filename
|
||||
assert result == "remote/file.pdf"
|
||||
|
||||
def test_multiple_processed_directories(self):
|
||||
"""Test path with multiple 'processed' directories."""
|
||||
result = extract_remote_path(
|
||||
"/base/processed/subdir/processed/file.pdf", "/base", "/remote"
|
||||
)
|
||||
from app.utils.filename_utils import extract_remote_path
|
||||
|
||||
result = extract_remote_path("/base/processed/subdir/processed/file.pdf", "/base", "/remote")
|
||||
# Should remove all 'processed' directories
|
||||
assert "processed" not in result.lower()
|
||||
|
||||
def test_remote_base_with_trailing_slash(self):
|
||||
"""Test remote base that already has trailing slash."""
|
||||
from app.utils.filename_utils import extract_remote_path
|
||||
|
||||
result = extract_remote_path("/base/file.pdf", "/base", "/remote/")
|
||||
# Should handle gracefully
|
||||
assert result.startswith("remote/")
|
||||
|
||||
def test_empty_remote_base(self):
|
||||
"""Test with empty remote base."""
|
||||
from app.utils.filename_utils import extract_remote_path
|
||||
|
||||
result = extract_remote_path("/base/subdir/file.pdf", "/base", "")
|
||||
assert result == "subdir/file.pdf"
|
||||
|
||||
def test_windows_style_separators(self, monkeypatch):
|
||||
"""Test handling of Windows-style path separators."""
|
||||
from app.utils.filename_utils import extract_remote_path
|
||||
|
||||
result = extract_remote_path("/base/subdir/file.pdf", "/base", "/remote")
|
||||
# Should use forward slashes in output
|
||||
assert "\\" not in result
|
||||
|
||||
Reference in New Issue
Block a user