Exemple #1
0
    def test_build_section_tree_appendix_through(self):
        line1 = u"§ 201.20 Super Awesome Section"
        line2 = "\n(a) references Model Forms A-30(a) through (b)"

        tree = reg_text.build_section_tree(line1+line2, 201)
        self.assertEqual(tree.text, "\n")
        self.assertEqual(1, len(tree.children))
Exemple #2
0
    def test_build_section_tree_nonspace(self):
        line1 = u"§ 201.20. Super Awesome Section"
        line2 = "\nContents contents"

        tree = reg_text.build_section_tree(line1+line2, 201)
        self.assertEqual(line2, tree.text)
        self.assertEqual(['201', '20'], tree.label)
        self.assertEqual(line1, tree.title)
        self.assertEqual(0, len(tree.children))
Exemple #3
0
 def test_build_section_tree(self):
     """Should be just like build_paragraph tree, but with a label"""
     line1 = u"§ 201.20 Super Awesome Section"
     line2 = u"\nThis (a) is a good (1) test (2) of (3) some (b) body."
     tree = reg_text.build_section_tree(line1+line2, 201)
     p_tree = reg_text.regParser.build_tree(line2, label=['201', '20'])
     self.assertEqual(p_tree.text, tree.text)
     self.assertEqual(p_tree.children, tree.children)
     self.assertEqual(['201', '20'], tree.label)
     self.assertEqual(line1, tree.title)
Exemple #4
0
    def test_build_section_tree_a_or_b1(self):
        line1 = u"§ 201.20 Super Awesome Section"
        line2 = "\n(a) a (b) b (c) see paragraph (a) or (b)(1) of "
        line2 += "this section"

        tree = reg_text.build_section_tree(line1+line2, 201)
        self.assertEqual(tree.text, "\n")
        self.assertEqual(3, len(tree.children))
        child = tree.children[2]
        self.assertEqual(child.text, "(c) see paragraph (a) or (b)(1) " +
                                     "of this section")
        self.assertEqual(0, len(child.children))
Exemple #5
0
    def test_build_section_tree_appendix(self):
        """Should should not break on references to appendices."""
        line1 = u"§ 201.20 Super Awesome Section"
        line2a = "\n(a) Par 1 references Q-5(b) through (d) of Appendix Q"
        line2b = "\n(a) Par 1 references Q-5(a) through (d) of Appendix Q"
        line2c = "\n(a) Par 1 references Q-5(a) of Appendix Q"

        for line2 in [line2a, line2b, line2c]:
            tree = reg_text.build_section_tree(line1+line2, 201)
            self.assertEqual(tree.text, "\n")
            self.assertEqual(1, len(tree.children))
            child = tree.children[0]
            self.assertEqual(child.text, line2[1:])
            self.assertEqual(0, len(child.children))
Exemple #6
0
    def test_build_section_tree_italics_as_plaintext(self):
        line1 = u"§ 201.20 Super Awesome Section"
        line2 = "\n(a)(1)(i) paragraphs (c)(2)(ii)(A)(1) and (B) content"

        tree = reg_text.build_section_tree(line1+line2, 201)
        self.assertEqual(1, len(tree.children))
        self.assertEqual(['201', '20'], tree.label)
        tree = tree.children[0]
        self.assertEqual(1, len(tree.children))
        self.assertEqual(['201', '20', 'a'], tree.label)
        tree = tree.children[0]
        self.assertEqual(1, len(tree.children))
        self.assertEqual(['201', '20', 'a', '1'], tree.label)
        tree = tree.children[0]
        self.assertEqual(0, len(tree.children))
        self.assertEqual(['201', '20', 'a', '1', 'i'], tree.label)