def test_section_set_level(self):
     s = Section("Test section", level=4)
     self.assertEqual(s.title, "Test section")
     self.assertEqual(s.name, "Test_section")
     self.assertEqual(s.level, 4)
     self.assertEqual(
         s.html(), "<div id='Test_section'>\n"
         "<h4>Test section</h4>\n"
         "</div>")
 def test_section_no_content(self):
     s = Section("Empty section")
     self.assertEqual(s.title, "Empty section")
     self.assertEqual(s.name, "Empty_section")
     self.assertEqual(s.level, 2)
     self.assertEqual(
         s.html(), "<div id='Empty_section'>\n"
         "<h2>Empty section</h2>\n"
         "</div>")
 def test_section_set_name(self):
     s = Section("Test section", name="awesome_section")
     self.assertEqual(s.title, "Test section")
     self.assertEqual(s.name, "awesome_section")
     self.assertEqual(s.level, 2)
     self.assertEqual(
         s.html(), "<div id='awesome_section'>\n"
         "<h2>Test section</h2>\n"
         "</div>")
 def test_empty_section_with_css_class(self):
     s = Section()
     s.add_css_classes("clear")
     self.assertEqual(s.title,None)
     self.assertEqual(s.name,None)
     self.assertEqual(s.level,2)
     self.assertEqual(s.html(),
                      "<div class='clear'>\n"
                      "</div>")
 def test_section_with_subsection_and_css_classes(self):
     s = Section("Section with subsection and CSS classes")
     sub = s.add_subsection("Subsection", css_classes=("subsection", "new"))
     self.assertTrue(isinstance(sub, Section))
     self.assertEqual(s.title, "Section with subsection and CSS classes")
     self.assertEqual(s.name, "Section_with_subsection_and_CSS_classes")
     self.assertEqual(s.level, 2)
     self.assertEqual(sub.level, 3)
     self.assertEqual(
         s.html(), "<div id='Section_with_subsection_and_CSS_classes'>\n"
         "<h2>Section with subsection and CSS classes</h2>\n"
         "<div id='Subsection' class='subsection new'>\n"
         "<h3>Subsection</h3>\n"
         "</div>\n"
         "</div>")
 def test_section_with_subsection(self):
     s = Section("Section with subsection")
     sub = s.add_subsection("Subsection")
     self.assertTrue(isinstance(sub, Section))
     self.assertEqual(s.title, "Section with subsection")
     self.assertEqual(s.name, "Section_with_subsection")
     self.assertEqual(s.level, 2)
     self.assertEqual(sub.level, 3)
     self.assertEqual(
         s.html(), "<div id='Section_with_subsection'>\n"
         "<h2>Section with subsection</h2>\n"
         "<div id='Subsection'>\n"
         "<h3>Subsection</h3>\n"
         "</div>\n"
         "</div>")
 def test_document_add_existing_section(self):
     d = Document("Document with existing section")
     s = Section("External section")
     d.add_section(section=s)
     self.assertEqual(
         d.html(), "<h1>Document with existing section</h1>\n"
         "<div id='External_section'>\n"
         "<h2>External section</h2>\n"
         "</div>")
 def test_section_with_content(self):
     s = Section("Section with content")
     s.add("Some stuff")
     self.assertEqual(s.title, "Section with content")
     self.assertEqual(s.name, "Section_with_content")
     self.assertEqual(s.level, 2)
     self.assertEqual(
         s.html(), "<div id='Section_with_content'>\n"
         "<h2>Section with content</h2>\n"
         "<p>Some stuff</p>\n"
         "</div>")
     s.add("More stuff", "and still more!")
     self.assertEqual(
         s.html(), "<div id='Section_with_content'>\n"
         "<h2>Section with content</h2>\n"
         "<p>Some stuff</p>\n"
         "<p>More stuff</p>\n"
         "<p>and still more!</p>\n"
         "</div>")
 def test_section_add_css_classes(self):
     s = Section("Test section")
     s.add_css_classes("section")
     self.assertEqual(s.title,"Test section")
     self.assertEqual(s.name,"Test_section")
     self.assertEqual(s.level,2)
     self.assertEqual(s.css_classes,["section",])
     self.assertEqual(s.html(),
                      "<div id='Test_section' class='section'>\n"
                      "<h2>Test section</h2>\n"
                      "</div>")
     s.add_css_classes("space-cadet","big")
     self.assertEqual(s.css_classes,["section",
                                     "space-cadet",
                                     "big",])
     self.assertEqual(s.html(),
                      "<div id='Test_section' "
                      "class='section space-cadet big'>\n"
                      "<h2>Test section</h2>\n"
                      "</div>")
 def test_section_with_external_subsection(self):
     s = Section("Section with external subsection")
     sub = Section("External subsection")
     self.assertEqual(sub.level, 2)
     s.add_subsection(section=sub)
     self.assertTrue(isinstance(sub, Section))
     self.assertEqual(s.title, "Section with external subsection")
     self.assertEqual(s.name, "Section_with_external_subsection")
     self.assertEqual(
         s.html(), "<div id='Section_with_external_subsection'>\n"
         "<h2>Section with external subsection</h2>\n"
         "<div id='External_subsection'>\n"
         "<h2>External subsection</h2>\n"
         "</div>\n"
         "</div>")
 def test_link_to_section(self):
     s = Section("Introduction", name='intro_section')
     ahref = Link("Introduction", s)
     self.assertEqual(ahref.href, "#intro_section")
     self.assertEqual(ahref.html(),
                      "<a href='#intro_section'>Introduction</a>")
 def test_empty_section(self):
     s = Section()
     self.assertEqual(s.title, None)
     self.assertEqual(s.name, None)
     self.assertEqual(s.level, 2)
     self.assertEqual(s.html(), "")