mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
- Introduced tests for various formatter classes including TextFormatter, DurationFormatter, SizeFormatter, DateFormatter, and more to ensure correct formatting behavior. - Added tests for service classes such as FileTreeService, MetadataService, and RenameService, covering directory validation, metadata extraction, and file renaming functionalities. - Implemented utility tests for LanguageCodeExtractor, PatternExtractor, and FrameClassMatcher to validate their extraction and matching capabilities. - Updated test cases to use datasets for better maintainability and clarity. - Enhanced error handling tests to ensure robustness against missing or invalid data.
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import pytest
|
|
from pathlib import Path
|
|
from renamer.extractors.fileinfo_extractor import FileInfoExtractor
|
|
|
|
|
|
class TestFileInfoExtractor:
|
|
@pytest.fixture
|
|
def extractor(self, test_file):
|
|
return FileInfoExtractor(test_file)
|
|
|
|
@pytest.fixture
|
|
def test_file(self):
|
|
"""Use the filename_patterns.json dataset file for testing"""
|
|
return Path(__file__).parent / "datasets" / "filenames" / "filename_patterns.json"
|
|
|
|
def test_extract_size(self, extractor):
|
|
"""Test extracting file size"""
|
|
size = extractor.extract_size()
|
|
assert isinstance(size, int)
|
|
assert size > 0
|
|
|
|
def test_extract_modification_time(self, extractor):
|
|
"""Test extracting modification time"""
|
|
mtime = extractor.extract_modification_time()
|
|
assert isinstance(mtime, float)
|
|
assert mtime > 0
|
|
|
|
def test_extract_file_name(self, extractor):
|
|
"""Test extracting file name"""
|
|
name = extractor.extract_file_name()
|
|
assert isinstance(name, str)
|
|
assert name == "filename_patterns.json"
|
|
|
|
def test_extract_file_path(self, extractor):
|
|
"""Test extracting file path"""
|
|
path = extractor.extract_file_path()
|
|
assert isinstance(path, str)
|
|
assert "filename_patterns.json" in path |