def test_process_new_subpart(self): xml = self.new_subpart_xml() notice_xml = etree.fromstring(xml) par = notice_xml.xpath('//AMDPAR')[1] amended_label = ('POST', '105-Subpart:B') notice = {'cfr_part': '105'} changes = build.process_new_subpart(notice, amended_label, par) new_nodes_added = ['105-Subpart-B', '105-30', '105-30-a'] self.assertEqual(new_nodes_added, changes.keys()) for l, n in changes.items(): self.assertEqual(n['action'], 'POST') self.assertEqual( changes['105-Subpart-B']['node']['node_type'], 'subpart')
def test_process_amendments_markerless(self): amdpar = u"1. Revise [label:105-11-p5] as blah" with XMLBuilder("REGTEXT", PART="105", TITLE="12") as ctx: ctx.AMDPAR(amdpar) with ctx.SECTION(): ctx.SECTNO(u"§ 105.11") ctx.SUBJECT("Purpose.") ctx.STARS() ctx.P("Some text here") ParseAMDPARs().transform(ctx.xml) amendment = amendments.fetch_amendments(ctx.xml)[0] changes = dict(amendment['changes']) self.assertEqual(amendment['instruction'], amdpar) self.assertEqual(amendment['cfr_part'], '105') six.assertCountEqual(self, changes.keys(), ['105-11-p5']) changes = changes['105-11-p5'][0] self.assertEqual(changes['action'], 'PUT')
def test_process_amendments_insert_in_order(self): amdpar = '[insert-in-order] [label:123-45-p6]' with XMLBuilder("ROOT") as ctx: with ctx.REGTEXT(TITLE="10"): ctx.AMDPAR(amdpar) with ctx.SECTION(): ctx.SECTNO(u"§ 123.45") ctx.SUBJECT("Some Subject.") ctx.STARS() ctx.P("This is the sixth paragraph") ctx.STARS() ParseAMDPARs().transform(ctx.xml) amendment = amendments.fetch_amendments(ctx.xml)[0] changes = dict(amendment['changes']) self.assertEqual(amendment['instruction'], amdpar) self.assertEqual(amendment['cfr_part'], '123') six.assertCountEqual(self, ['123-45-p6'], changes.keys()) self.assertEqual('INSERT', changes['123-45-p6'][0]['action'])
def test_process_amendments(self): amdpar = (u"2. Designate §§ 105.1 through 105.3 as subpart A under " u"the heading.") with XMLBuilder("REGTEXT", PART="105", TITLE="12") as ctx: with ctx.SUBPART(): ctx.HD(u"Subpart A—General", SOURCE="HED") ctx.AMDPAR(amdpar) ParseAMDPARs().transform(ctx.xml) amendment = amendments.fetch_amendments(ctx.xml)[0] changes = dict(amendment['changes']) self.assertEqual(amendment['instruction'], amdpar) self.assertEqual(amendment['cfr_part'], '105') six.assertCountEqual(self, ['105-1', '105-2', '105-3'], changes.keys()) for change_list in changes.values(): self.assertEqual(1, len(change_list)) change = change_list[0] self.assertEqual(change['destination'], ['105', 'Subpart', 'A']) self.assertEqual(change['action'], 'DESIGNATE')
def test_process_amendments_section(self): amdpar = u"3. In § 105.1, revise paragraph (b) to read as follows:" with XMLBuilder("REGTEXT", PART="105", TITLE="12") as ctx: ctx.AMDPAR(amdpar) with ctx.SECTION(): ctx.SECTNO(u"§ 105.1") ctx.SUBJECT("Purpose.") ctx.STARS() ctx.P("(b) This part carries out.") ParseAMDPARs().transform(ctx.xml) amendment = amendments.fetch_amendments(ctx.xml)[0] changes = dict(amendment['changes']) self.assertEqual(amendment['instruction'], amdpar) self.assertEqual(amendment['cfr_part'], '105') six.assertCountEqual(self, changes.keys(), ['105-1-b']) changes = changes['105-1-b'][0] self.assertEqual(changes['action'], 'PUT') self.assertTrue(changes['node']['text'].startswith( u'(b) This part carries out.'))