def test_no_chapters(self): lines = """\ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed do eiusmod tempor. Incididunt ut labore et dolore magna aliqua.""".splitlines() chapter_line_numbers = [0] wordcounts = get_chapter_wordcounts(chapter_line_numbers, lines) self.assertEqual(wordcounts, [19])
def test_default_run(self): lines = """\ >> CHAPTER 1 Lorem ipsum. Line 2. >> CHAPTER 2 Exciting ending! What will happen next!""".splitlines() chapter_line_numbers = [0, 1, 5] wordcounts = get_chapter_wordcounts(chapter_line_numbers, lines) self.assertEqual(wordcounts, [0, 4, 6])
def test_empty_chapters(self): lines = """\ >> CHAPTER 1 >> CHAPTER 2 >> CHAPTER 3 """.splitlines() chapter_line_numbers = [0, 2, 3, 6] wordcounts = get_chapter_wordcounts(chapter_line_numbers, lines) self.assertEqual(wordcounts, [0, 0, 0, 0])
def test_default_run_with_prologue(self): lines = """\ A prologue! Yes! How exciting. And some more... >> CHAPTER 1 Lorem ipsum. Line 2. >> CHAPTER 2 Exciting ending! What will happen next!""".splitlines() chapter_line_numbers = [0, 3, 7] wordcounts = get_chapter_wordcounts(chapter_line_numbers, lines) self.assertEqual(wordcounts, [8, 4, 6])
def test_no_lines_at_all(self): lines = [] chapter_line_numbers = [] wordcounts = get_chapter_wordcounts(chapter_line_numbers, lines) self.assertEqual(wordcounts, [])