28 lines
996 B
Python
28 lines
996 B
Python
import unittest
|
|
|
|
from app.worker import normalize_chapter_plan, render_chapter_plan
|
|
|
|
|
|
class ChapterPlanTest(unittest.TestCase):
|
|
def test_normalize_chapter_plan_makes_first_topic_start_at_zero(self):
|
|
chapters = normalize_chapter_plan(
|
|
{
|
|
"chapters": [
|
|
{"title": "Вступление", "startSeconds": 12},
|
|
{"title": "Основная тема", "startSeconds": 340},
|
|
]
|
|
},
|
|
900,
|
|
)
|
|
|
|
self.assertEqual(chapters[0]["startSeconds"], 0)
|
|
self.assertEqual(chapters[1]["startSeconds"], 340)
|
|
self.assertIn("00:00 Вступление", render_chapter_plan(chapters))
|
|
|
|
def test_normalize_chapter_plan_rejects_single_topic(self):
|
|
with self.assertRaisesRegex(RuntimeError, "слишком мало"):
|
|
normalize_chapter_plan({"chapters": [{"title": "Тема", "startSeconds": 0}]}, 900)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|