コード例 #1
0
    def test_process_xml_fill_effective_date(self):
        xml = """
        <ROOT>
            <DATES>
                <P>Effective January 1, 2002</P>
            </DATES>
        </ROOT>"""
        xml = etree.fromstring(xml)

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'document_number': '1999-12345', 'effective_on': '2002-02-02'}
        notice = build.process_xml(notice, xml)
        self.assertEqual('2002-02-02', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'document_number': '1999-12345',}
        notice = build.process_xml(notice, xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'document_number': '1999-12345', 'effective_on': None}
        notice = build.process_xml(notice, xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])
コード例 #2
0
    def test_process_xml_fill_effective_date(self):
        with XMLBuilder("ROOT") as ctx:
            with ctx.DATES():
                ctx.P("Effective January 1, 2002")

        notice = {
            'cfr_parts': ['902'],
            'meta': {
                'start_page': 10
            },
            'effective_on': '2002-02-02'
        }
        notice = build.process_xml(notice, ctx.xml)
        self.assertEqual('2002-02-02', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10}}
        notice = build.process_xml(notice, ctx.xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])

        notice = {
            'cfr_parts': ['902'],
            'meta': {
                'start_page': 10
            },
            'effective_on': None
        }
        notice = build.process_xml(notice, ctx.xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])
コード例 #3
0
 def test_process_xml(self):
     """Integration test for xml processing"""
     with self.tree.builder("ROOT") as root:
         with root.SUPLINF() as suplinf:
             with suplinf.FURINF() as furinf:
                 furinf.HD("CONTACT INFO:")
                 furinf.P("Extra contact info here")
             with suplinf.ADD() as add:
                 add.P("Email: [email protected]")
                 add.P("Extra instructions")
             suplinf.HD("Supplementary Info", SOURCE="HED")
             suplinf.HD("V. Section-by-Section Analysis", SOURCE="HD1")
             suplinf.HD("8(q) Words", SOURCE="HD2")
             suplinf.P("Content")
             suplinf.HD("Section that follows", SOURCE="HD1")
             suplinf.P("Following Content")
     notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 100}}
     self.assertEqual(build.process_xml(notice, self.tree.render_xml()), {
         'cfr_parts': ['9292'],
         'footnotes': {},
         'meta': {'start_page': 100},
         'addresses': {
             'methods': [('Email', '*****@*****.**')],
             'instructions': ['Extra instructions']
         },
         'contact': 'Extra contact info here',
         'section_by_section': [{
             'title': '8(q) Words',
             'paragraphs': ['Content'],
             'children': [],
             'footnote_refs': [],
             'page': 100,
             'labels': ['9292-8-q']
         }],
     })
コード例 #4
0
 def test_process_xml_missing_fields(self):
     xml = """
     <ROOT>
         <SUPLINF>
             <HD SOURCE="HED">Supplementary Info</HD>
             <HD SOURCE="HD1">V. Section-by-Section Analysis</HD>
             <HD SOURCE="HD2">8(q) Words</HD>
             <P>Content</P>
             <HD SOURCE="HD1">Section that follows</HD>
             <P>Following Content</P>
         </SUPLINF>
     </ROOT>"""
     notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 210},
               'document_number': '1999-12345',}
     self.assertEqual(build.process_xml(notice, etree.fromstring(xml)), {
         'cfr_parts': ['9292'],
         'footnotes': {},
         'meta': {'start_page': 210},
         'document_number': '1999-12345',
         'section_by_section': [{
             'title': '8(q) Words',
             'paragraphs': ['Content'],
             'children': [],
             'footnote_refs': [],
             'page': 210,
             'labels': ['9292-8-q']
         }],
     })
コード例 #5
0
 def test_process_xml_missing_fields(self):
     with XMLBuilder("ROOT") as ctx:
         with ctx.SUPLINF():
             ctx.HD("Supplementary Info", SOURCE="HED")
             ctx.HD("V. Section-by-Section Analysis", SOURCE="HD1")
             ctx.HD("8(q) Words", SOURCE="HD2")
             ctx.P("Content")
             ctx.HD("Section that follows", SOURCE="HD1")
             ctx.P("Following Content")
     notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 210}}
     self.assertEqual(
         build.process_xml(notice, ctx.xml), {
             'cfr_parts': ['9292'],
             'footnotes': {},
             'meta': {
                 'start_page': 210
             },
             'section_by_section': [{
                 'title': '8(q) Words',
                 'paragraphs': ['Content'],
                 'children': [],
                 'footnote_refs': [],
                 'page': 210,
                 'labels': ['9292-8-q']
             }],
         })
コード例 #6
0
 def test_process_xml_missing_fields(self):
     xml = """
     <ROOT>
         <SUPLINF>
             <HD SOURCE="HED">Supplementary Info</HD>
             <HD SOURCE="HD1">V. Section-by-Section Analysis</HD>
             <HD SOURCE="HD2">8(q) Words</HD>
             <P>Content</P>
             <HD SOURCE="HD1">Section that follows</HD>
             <P>Following Content</P>
         </SUPLINF>
     </ROOT>"""
     notice = {"cfr_parts": ["9292"], "meta": {"start_page": 210}}
     self.assertEqual(
         build.process_xml(notice, etree.fromstring(xml)),
         {
             "cfr_parts": ["9292"],
             "footnotes": {},
             "meta": {"start_page": 210},
             "section_by_section": [
                 {
                     "title": "8(q) Words",
                     "paragraphs": ["Content"],
                     "children": [],
                     "footnote_refs": [],
                     "page": 210,
                     "labels": ["9292-8-q"],
                 }
             ],
         },
     )
コード例 #7
0
 def test_process_xml(self):
     """Integration test for xml processing"""
     xml = """
     <ROOT>
         <SUPLINF>
             <FURINF>
                 <HD>CONTACT INFO:</HD>
                 <P>Extra contact info here</P>
             </FURINF>
             <ADD>
                 <P>Email: [email protected]</P>
                 <P>Extra instructions</P>
             </ADD>
             <HD SOURCE="HED">Supplementary Info</HD>
             <HD SOURCE="HD1">V. Section-by-Section Analysis</HD>
             <HD SOURCE="HD2">8(q) Words</HD>
             <P>Content</P>
             <HD SOURCE="HD1">Section that follows</HD>
             <P>Following Content</P>
         </SUPLINF>
     </ROOT>"""
     notice = {
         'cfr_parts': ['9292'],
         'cfr_part': '9292',
         'meta': {
             'start_page': 100
         },
         'document_number': '1999-12345'
     }
     self.assertEqual(
         build.process_xml(notice, etree.fromstring(xml)), {
             'cfr_parts': ['9292'],
             'cfr_part':
             '9292',
             'footnotes': {},
             'meta': {
                 'start_page': 100
             },
             'document_number':
             '1999-12345',
             'addresses': {
                 'methods': [('Email', '*****@*****.**')],
                 'instructions': ['Extra instructions']
             },
             'contact':
             'Extra contact info here',
             'section_by_section': [{
                 'title': '8(q) Words',
                 'paragraphs': ['Content'],
                 'children': [],
                 'footnote_refs': [],
                 'page': 100,
                 'labels': ['9292-8-q']
             }],
         })
コード例 #8
0
    def test_process_xml_fill_effective_date(self):
        with XMLBuilder("ROOT") as ctx:
            with ctx.DATES():
                ctx.P("Effective January 1, 2002")

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'effective_on': '2002-02-02'}
        notice = build.process_xml(notice, ctx.xml)
        self.assertEqual('2002-02-02', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10}}
        notice = build.process_xml(notice, ctx.xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'effective_on': None}
        notice = build.process_xml(notice, ctx.xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])
コード例 #9
0
    def test_process_xml(self):
        """Integration test for xml processing, including validating that some
        fields may be missing"""
        with XMLBuilder("ROOT") as ctx:
            with ctx.SUPLINF():
                ctx.HD("Supplementary Info", SOURCE="HED")
                ctx.HD("V. Section-by-Section Analysis", SOURCE="HD1")
                ctx.HD("8(q) Words", SOURCE="HD2")
                ctx.P("Content")
                ctx.HD("Section that follows", SOURCE="HD1")
                ctx.P("Following Content")

        notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 100}}
        self.assertEqual(build.process_xml(notice, ctx.xml), {
            'cfr_parts': ['9292'],
            'footnotes': {},
            'meta': {'start_page': 100},
            'section_by_section': [{
                'title': '8(q) Words',
                'paragraphs': ['Content'],
                'children': [],
                'footnote_refs': [],
                'page': 100,
                'labels': ['9292-8-q']
            }],
        })

        notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 210}}
        self.assertEqual(build.process_xml(notice, ctx.xml), {
            'cfr_parts': ['9292'],
            'footnotes': {},
            'meta': {'start_page': 210},
            'section_by_section': [{
                'title': '8(q) Words',
                'paragraphs': ['Content'],
                'children': [],
                'footnote_refs': [],
                'page': 210,
                'labels': ['9292-8-q']
            }],
        })
コード例 #10
0
    def test_process_xml_fill_effective_date(self):
        with self.tree.builder("ROOT") as root:
            with root.DATES() as dates:
                dates.P("Effective January 1, 2002")
        xml = self.tree.render_xml()

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'effective_on': '2002-02-02'}
        notice = build.process_xml(notice, xml)
        self.assertEqual('2002-02-02', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10}}
        notice = build.process_xml(notice, xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])

        notice = {'cfr_parts': ['902'], 'meta': {'start_page': 10},
                  'effective_on': None}
        notice = build.process_xml(notice, xml)
        # Uses the date found in the XML
        self.assertEqual('2002-01-01', notice['effective_on'])
コード例 #11
0
    def test_process_xml_fill_effective_date(self):
        xml = """
        <ROOT>
            <DATES>
                <P>Effective January 1, 2002</P>
            </DATES>
        </ROOT>"""
        xml = etree.fromstring(xml)

        notice = {"cfr_parts": ["902"], "meta": {"start_page": 10}, "effective_on": "2002-02-02"}
        notice = build.process_xml(notice, xml)
        self.assertEqual("2002-02-02", notice["effective_on"])

        notice = {"cfr_parts": ["902"], "meta": {"start_page": 10}}
        notice = build.process_xml(notice, xml)
        # Uses the date found in the XML
        self.assertEqual("2002-01-01", notice["effective_on"])

        notice = {"cfr_parts": ["902"], "meta": {"start_page": 10}, "effective_on": None}
        notice = build.process_xml(notice, xml)
        # Uses the date found in the XML
        self.assertEqual("2002-01-01", notice["effective_on"])
コード例 #12
0
 def test_process_xml(self):
     """Integration test for xml processing"""
     xml = """
     <ROOT>
         <SUPLINF>
             <FURINF>
                 <HD>CONTACT INFO:</HD>
                 <P>Extra contact info here</P>
             </FURINF>
             <ADD>
                 <P>Email: [email protected]</P>
                 <P>Extra instructions</P>
             </ADD>
             <HD SOURCE="HED">Supplementary Info</HD>
             <HD SOURCE="HD1">V. Section-by-Section Analysis</HD>
             <HD SOURCE="HD2">8(q) Words</HD>
             <P>Content</P>
             <HD SOURCE="HD1">Section that follows</HD>
             <P>Following Content</P>
         </SUPLINF>
     </ROOT>"""
     notice = {'cfr_parts': ['9292'], 'cfr_part': '9292',
               'meta': {'start_page': 100},
               'document_number': '1999-12345'}
     self.assertEqual(build.process_xml(notice, etree.fromstring(xml)), {
         'cfr_parts': ['9292'],
         'cfr_part': '9292',
         'footnotes': {},
         'meta': {'start_page': 100},
         'document_number': '1999-12345',
         'addresses': {
             'methods': [('Email', '*****@*****.**')],
             'instructions': ['Extra instructions']
         },
         'contact': 'Extra contact info here',
         'section_by_section': [{
             'title': '8(q) Words',
             'paragraphs': ['Content'],
             'children': [],
             'footnote_refs': [],
             'page': 100,
             'labels': ['9292-8-q']
         }],
     })
コード例 #13
0
 def test_process_xml(self):
     """Integration test for xml processing"""
     xml = """
     <ROOT>
         <SUPLINF>
             <FURINF>
                 <HD>CONTACT INFO:</HD>
                 <P>Extra contact info here</P>
             </FURINF>
             <ADD>
                 <P>Email: [email protected]</P>
                 <P>Extra instructions</P>
             </ADD>
             <HD SOURCE="HED">Supplementary Info</HD>
             <HD SOURCE="HD1">V. Section-by-Section Analysis</HD>
             <HD SOURCE="HD2">8(q) Words</HD>
             <P>Content</P>
             <HD SOURCE="HD1">Section that follows</HD>
             <P>Following Content</P>
         </SUPLINF>
     </ROOT>"""
     notice = {"cfr_parts": ["9292"], "meta": {"start_page": 100}}
     self.assertEqual(
         build.process_xml(notice, etree.fromstring(xml)),
         {
             "cfr_parts": ["9292"],
             "footnotes": {},
             "meta": {"start_page": 100},
             "addresses": {"methods": [("Email", "*****@*****.**")], "instructions": ["Extra instructions"]},
             "contact": "Extra contact info here",
             "section_by_section": [
                 {
                     "title": "8(q) Words",
                     "paragraphs": ["Content"],
                     "children": [],
                     "footnote_refs": [],
                     "page": 100,
                     "labels": ["9292-8-q"],
                 }
             ],
         },
     )
コード例 #14
0
 def test_process_xml(self):
     """Integration test for xml processing"""
     with XMLBuilder("ROOT") as ctx:
         with ctx.SUPLINF():
             with ctx.FURINF():
                 ctx.HD("CONTACT INFO:")
                 ctx.P("Extra contact info here")
             with ctx.ADD():
                 ctx.P("Email: [email protected]")
                 ctx.P("Extra instructions")
             ctx.HD("Supplementary Info", SOURCE="HED")
             ctx.HD("V. Section-by-Section Analysis", SOURCE="HD1")
             ctx.HD("8(q) Words", SOURCE="HD2")
             ctx.P("Content")
             ctx.HD("Section that follows", SOURCE="HD1")
             ctx.P("Following Content")
     notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 100}}
     self.assertEqual(
         build.process_xml(notice, ctx.xml), {
             'cfr_parts': ['9292'],
             'footnotes': {},
             'meta': {
                 'start_page': 100
             },
             'addresses': {
                 'methods': [('Email', '*****@*****.**')],
                 'instructions': ['Extra instructions']
             },
             'contact':
             'Extra contact info here',
             'section_by_section': [{
                 'title': '8(q) Words',
                 'paragraphs': ['Content'],
                 'children': [],
                 'footnote_refs': [],
                 'page': 100,
                 'labels': ['9292-8-q']
             }],
         })
コード例 #15
0
 def test_process_xml_missing_fields(self):
     with self.tree.builder("ROOT") as root:
         with root.SUPLINF() as suplinf:
             suplinf.HD("Supplementary Info", SOURCE="HED")
             suplinf.HD("V. Section-by-Section Analysis", SOURCE="HD1")
             suplinf.HD("8(q) Words", SOURCE="HD2")
             suplinf.P("Content")
             suplinf.HD("Section that follows", SOURCE="HD1")
             suplinf.P("Following Content")
     notice = {'cfr_parts': ['9292'], 'meta': {'start_page': 210}}
     self.assertEqual(build.process_xml(notice, self.tree.render_xml()), {
         'cfr_parts': ['9292'],
         'footnotes': {},
         'meta': {'start_page': 210},
         'section_by_section': [{
             'title': '8(q) Words',
             'paragraphs': ['Content'],
             'children': [],
             'footnote_refs': [],
             'page': 210,
             'labels': ['9292-8-q']
         }],
     })