Fix regex issues
This commit is contained in:
61
tests/unit/test_helper.py
Normal file
61
tests/unit/test_helper.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
SRC_ROOT = Path(__file__).resolve().parents[2] / "src"
|
||||
|
||||
if str(SRC_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(SRC_ROOT))
|
||||
|
||||
|
||||
from ffx.helper import ( # noqa: E402
|
||||
filterFilename,
|
||||
formatRichColor,
|
||||
removeRichColor,
|
||||
substituteTmdbFilename,
|
||||
)
|
||||
|
||||
|
||||
class HelperTests(unittest.TestCase):
|
||||
def test_filter_filename_replaces_and_removes_problem_characters(self):
|
||||
self.assertEqual(
|
||||
"A-B;C#",
|
||||
filterFilename(" A/B:C*'?♥’ "),
|
||||
)
|
||||
|
||||
def test_substitute_tmdb_filename_removes_filler_marker(self):
|
||||
self.assertEqual(
|
||||
"Episode Name",
|
||||
substituteTmdbFilename("Episode Name (*)"),
|
||||
)
|
||||
|
||||
def test_substitute_tmdb_filename_rewrites_single_episode_suffix(self):
|
||||
self.assertEqual(
|
||||
"Episode Name Teil 2",
|
||||
substituteTmdbFilename("Episode Name (2)"),
|
||||
)
|
||||
|
||||
def test_substitute_tmdb_filename_rewrites_episode_range_suffix(self):
|
||||
self.assertEqual(
|
||||
"Episode Name Teil 2-3",
|
||||
substituteTmdbFilename("Episode Name (2/3)"),
|
||||
)
|
||||
|
||||
def test_remove_rich_color_returns_inner_text(self):
|
||||
self.assertEqual(
|
||||
"value",
|
||||
removeRichColor(formatRichColor("value", "green")),
|
||||
)
|
||||
|
||||
def test_remove_rich_color_leaves_plain_text_unchanged(self):
|
||||
self.assertEqual(
|
||||
"plain text",
|
||||
removeRichColor("plain text"),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user