mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
- Introduced `auto_prefix_chapter_titles` setting in Job and PendingJob classes to control prefixing of chapter titles with "Chapter". - Updated job detail and settings templates to display and configure the new option. - Enhanced reader.js to manage playback controls, including chapter navigation and playback speed adjustments. - Implemented a new prepare_chapters.html template for chapter selection and configuration during job preparation. - Added tests for chapter title formatting and heading equivalence to ensure correct behavior of the new feature.
28 lines
967 B
Python
28 lines
967 B
Python
from abogen.web.conversion_runner import (
|
|
_format_spoken_chapter_title,
|
|
_headings_equivalent,
|
|
_strip_duplicate_heading_line,
|
|
)
|
|
|
|
|
|
def test_format_spoken_chapter_title_adds_prefix() -> None:
|
|
assert _format_spoken_chapter_title("1: A Tale", 1, True) == "Chapter 1: A Tale"
|
|
|
|
|
|
def test_format_spoken_chapter_title_respects_existing_prefix() -> None:
|
|
assert _format_spoken_chapter_title("Chapter 2: Story", 2, True) == "Chapter 2: Story"
|
|
|
|
|
|
def test_format_spoken_chapter_title_handles_empty_title() -> None:
|
|
assert _format_spoken_chapter_title("", 4, True) == "Chapter 4"
|
|
|
|
|
|
def test_headings_equivalent_ignores_case_and_prefix() -> None:
|
|
assert _headings_equivalent("1: The House", "Chapter 1: The House")
|
|
|
|
|
|
def test_strip_duplicate_heading_line_removes_first_match() -> None:
|
|
text, removed = _strip_duplicate_heading_line("Chapter 3: Intro\nBody text", "Chapter 3: Intro")
|
|
assert removed is True
|
|
assert text.strip() == "Body text"
|