def test_preprocess_emph_tags(self): notice_xml = etree.fromstring(u""" <PART> <P>(<E T="03">a</E>) Content</P> <P>(<E T="03">a)</E> Content</P> <P><E T="03">(a</E>) Content</P> <P><E T="03">(a)</E> Content</P> </PART>""") notice_xml = build.preprocess_notice_xml(notice_xml) pars = notice_xml.xpath("//P") self.assertEqual(4, len(pars)) for par in pars: self.assertEqual(par.text, "(") self.assertEqual(1, len(par.getchildren())) em = par.getchildren()[0] self.assertEqual("E", em.tag) self.assertEqual("a", em.text) self.assertEqual(em.tail, ") Content") self.assertEqual(0, len(em.getchildren())) notice_xml = etree.fromstring(u""" <PART> <P><E T="03">Paragraph 22(a)(5)</E> Content</P> </PART>""") notice_xml = build.preprocess_notice_xml(notice_xml) pars = notice_xml.xpath("//P") self.assertEqual(1, len(pars)) em = pars[0].getchildren()[0] self.assertEqual(em.text, "Paragraph 22(a)(5)") self.assertEqual(em.tail, " Content")
def test_preprocess_notice_xml_improper_location(self): notice_xml = etree.fromstring(u""" <PART> <REGTEXT> <AMDPAR>1. In § 105.1, revise paragraph (b):</AMDPAR> <SECTION> <STARS /> <P>(b) Content</P> </SECTION> <AMDPAR> 3. In § 105.2, revise paragraph (a) to read as follows: </AMDPAR> </REGTEXT> <REGTEXT> <SECTION> <P>(a) Content</P> </SECTION> </REGTEXT> </PART>""") notice_xml = build.preprocess_notice_xml(notice_xml) amd1b, amd2a = notice_xml.xpath("//AMDPAR") self.assertEqual(amd1b.getparent().xpath(".//P")[0].text.strip(), "(b) Content") self.assertEqual(amd2a.getparent().xpath(".//P")[0].text.strip(), "(a) Content") notice_xml = etree.fromstring(u""" <PART> <REGTEXT PART="105"> <AMDPAR>1. In § 105.1, revise paragraph (b):</AMDPAR> <SECTION> <STARS /> <P>(b) Content</P> </SECTION> <AMDPAR> 3. In § 105.2, revise paragraph (a) to read as follows: </AMDPAR> </REGTEXT> <REGTEXT PART="107"> <SECTION> <P>(a) Content</P> </SECTION> </REGTEXT> </PART>""") notice_xml = build.preprocess_notice_xml(notice_xml) amd1b, amd2a = notice_xml.xpath("//AMDPAR") self.assertEqual(amd1b.getparent().xpath(".//P")[0].text.strip(), "(b) Content") self.assertEqual(amd2a.getparent().xpath(".//P")[0].text.strip(), "(b) Content")
def test_preprocess_notice_xml_interp_amds_are_ps2(self): notice_xml = etree.fromstring(u""" <PART> <REGTEXT> <AMDPAR>1. In Supplement I to Part 105,</AMDPAR> <P>A. Under Section 105.1, 1(b), paragraph 2 is revised</P> <P>The revisions are as follows</P> <HD SOURCE="HD1">Supplement I to Part 105</HD> <STARS /> <P><E T="03">1(b) Heading</E></P> <STARS /> <P>2. New Content</P> </REGTEXT> </PART>""") notice_xml = build.preprocess_notice_xml(notice_xml) amd1, amd1A, amd_other = notice_xml.xpath("//AMDPAR") self.assertEqual(amd1A.text.strip(), "A. Under Section 105.1, 1(b), " + "paragraph 2 is revised")