示例#1
0
 def test_interp_graph_parsing(self):
     soup = bS(self.interp_xml, 'lxml-xml')
     part_soup = soup.find('DIV5')
     PAYLOAD.parse_part(part_soup, '1002')
     part = PAYLOAD.part
     PAYLOAD.parse_version(part_soup, part)
     version = PAYLOAD.version
     interp_subpart = Subpart(
         title="Supplement I to Part {}".format(part.part_number),
         label="Official Interpretations",
         version=version)
     interp_subpart.save()
     interp = [div for div
               in part_soup.find_all('DIV9')
               if div.find('HEAD').text.startswith('Supplement I')][0]
     ecfr_importer.parse_interps(interp, part, interp_subpart)
     self.assertEqual(
         Subpart.objects.filter(title__contains='Supplement I').count(),
         1,
     )
示例#2
0
 def test_interp_inferred_section_graph_parsing(self):
     PAYLOAD.reset()
     self.assertEqual(PAYLOAD.interp_refs, {})
     soup = bS(self.interp_xml, 'lxml-xml')
     parts = soup.find_all('DIV5')
     part_soup = [div for div in parts if div['N'] == '1030'][0]
     PAYLOAD.parse_part(part_soup, '1030')
     part = PAYLOAD.part
     PAYLOAD.parse_version(part_soup, part)
     version = PAYLOAD.version
     interp_subpart = Subpart(
         title="Supplement I to Part {}".format(part.part_number),
         label="Official Interpretations",
         version=version)
     interp_subpart.save()
     interp = [div for div
               in part_soup.find_all('DIV9')
               if div.find('HEAD').text.startswith('Supplement I')][0]
     ecfr_importer.parse_interps(interp, part, interp_subpart)
     self.assertEqual(PAYLOAD.interp_refs['1']['c'], 'see(1-c-Interp)')