-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_infer_core.py
More file actions
36 lines (27 loc) · 1.36 KB
/
test_infer_core.py
File metadata and controls
36 lines (27 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
import infer_core
class InferCoreTests(unittest.TestCase):
def test_fold_text_preserves_l_stroke_signal(self) -> None:
self.assertEqual(infer_core.author_key("Łukasz Żmijewski"), "lukaszzmijewski")
def test_parse_volume_parts_handles_roman(self) -> None:
self.assertEqual(infer_core.parse_volume_parts("IV"), (4, "00"))
def test_format_volume_preserves_unknown_placeholder(self) -> None:
self.assertEqual(infer_core.format_volume(None), "Tom 00.00")
self.assertEqual(infer_core.format_volume((0, "00")), "Tom 00.00")
def test_format_title_with_genre_replaces_existing_suffix(self) -> None:
genre_suffix_re = __import__("re").compile(r"^(.*?)\s*\[([^\[\]]+)\]\s*$")
self.assertEqual(
infer_core.format_title_with_genre("Title [fantasy]", "sci-fi", genre_suffix_re=genre_suffix_re),
"Title [sci-fi]",
)
def test_split_title_genre_suffix_preserves_full_label(self) -> None:
genre_suffix_re = __import__("re").compile(r"^(.*?)\s*\[([^\[\]]+)\]\s*$")
self.assertEqual(
infer_core.split_title_genre_suffix(
"Title [kryminał, sensacja, thriller]",
genre_suffix_re=genre_suffix_re,
),
("Title", "kryminał, sensacja, thriller"),
)
if __name__ == "__main__":
unittest.main()