Exemplo n.º 1
0
class TestHtmlBody(unittest.TestCase):
    def setUp(self):
        self.Document = Document()
        self.DocumentWithChapter = Document()

        self.FirstChapterTitle = "this is the first chapter title"

        self.FirstChapter = Chapter(self.FirstChapterTitle)
        self.FirstChapterText = "this is text in the first chapter"
        self.FirstChapter.addText(self.FirstChapterText)
        self.DocumentWithChapter.addChapter(self.FirstChapter)

        self.SecondChapterTitle = "this is the second chapter title"
        self.SecondChapter = Chapter(self.SecondChapterTitle)
        self.DocumentWithChapter.addChapter(self.SecondChapter)

    def test_htmlPageHasBodyTag(self):
        page = getHtmlBody(self.Document)
        self.assertRegex(page, "<body>.*</body>")

    def test_htmlPageHasFirstChapter(self):
        page = getHtmlBody(self.DocumentWithChapter)
        self.assertRegex(
            page, f"<body><h1>{self.FirstChapterTitle}</h1>.*</body>")

    def test_htmlPageHasFirstChapterWithCorrectText(self):
        page = getHtmlBody(self.DocumentWithChapter)
        self.assertRegex(
            page, f".*</h1>{self.FirstChapterText}.*")

    def test_htmlPageHasSecondChapter(self):
        page = getHtmlBody(self.DocumentWithChapter)
        self.assertRegex(
            page,
            f"<body><h1>.*</h1>.*<h1>{self.SecondChapterTitle}</h1>.*</body>")
Exemplo n.º 2
0
    def setUp(self):
        self.Document = Document()
        self.DocumentWithChapter = Document()

        self.FirstChapterTitle = "this is the first chapter title"

        self.FirstChapter = Chapter(self.FirstChapterTitle)
        self.FirstChapterText = "this is text in the first chapter"
        self.FirstChapter.addText(self.FirstChapterText)
        self.DocumentWithChapter.addChapter(self.FirstChapter)

        self.SecondChapterTitle = "this is the second chapter title"
        self.SecondChapter = Chapter(self.SecondChapterTitle)
        self.DocumentWithChapter.addChapter(self.SecondChapter)
Exemplo n.º 3
0
 def test_canAddMoreText(self):
     chap = Chapter()
     text1 = "text1 blahBlah"
     chap.addText(text1)
     text2 = "text2 blahBlah"
     chap.addText(text2)
     self.assertIn(text1, chap.Text)
     self.assertIn(text2, chap.Text)
Exemplo n.º 4
0
 def test_ChapterHasTitle(self):
     title = "This is my title"
     chap = Chapter(title)
     self.assertEqual(chap.Title, title)
Exemplo n.º 5
0
 def test_chapter(self):
     chap = Chapter()
     self.assertIsNotNone(chap)
Exemplo n.º 6
0
 def test_canAddList(self):
     chap = Chapter()
     data = []
     data.append("item 1")
     chap.addList(data)
     self.assertIn(data, chap.Lists)
Exemplo n.º 7
0
 def test_ChapterCanAddText(self):
     text = "blahBlah"
     chap = Chapter()
     chap.addText(text)
     self.assertIn(text, chap.Text)
Exemplo n.º 8
0
 def test_ChapterCanLiveWithoutTitle(self):
     chap = Chapter()
     self.assertEqual(chap.Title, None)
Exemplo n.º 9
0
 def test_AddChapterToDocument(self):
     doc = Document()
     chapterTitle = "A new beginning"
     chapter = Chapter(chapterTitle)
     doc.addChapter(chapter)
     self.assertIn(chapter, doc.Chapters)