Ejemplo n.º 1
0
 def test_duplicate_dates_made_unique(self):
     ut_input = etree.fromstring(
         "<parent><unittitle>text<unitdate>3000</unitdate>, <unitdate>3000</unitdate>, and <unitdate>900</unitdate></unittitle></parent>"
     )
     ut_input = ut_input.xpath("unittitle")[0]
     ut_target = etree.fromstring(
         "<parent><unittitle>text</unittitle><unitdate>3000</unitdate><unitdate>900</unitdate></parent>"
     )
     self.assertEquals(
         etree.tostring(move_unitdates(ut_input, "move_and_clean")),
         etree.tostring(ut_target))
Ejemplo n.º 2
0
 def test_remove_empty_unittitle(self):
     ut_input = etree.fromstring(
         "<parent><unittitle><unitdate>3000</unitdate>, <unitdate>4000</unitdate>, and <unitdate>900</unitdate></unittitle></parent>"
     )
     ut_input = ut_input.xpath("unittitle")[0]
     ut_target = etree.fromstring(
         "<parent><unitdate>3000</unitdate><unitdate>4000</unitdate><unitdate>900</unitdate></parent>"
     )
     self.assertEquals(
         etree.tostring(move_unitdates(ut_input, "move_and_clean")),
         etree.tostring(ut_target))
Ejemplo n.º 3
0
 def test_calcify_with_extra_tags(self):
     unittitle_input = etree.fromstring(
         "<parent><unittitle>text <unitdate>3000</unitdate> more text <corpname>corp</corpname></unittitle><sibling>b</sibling></parent>"
     )
     unittitle_input = unittitle_input.xpath("unittitle")[0]
     unittitle_target = etree.fromstring(
         "<parent><unittitle>text 3000 more text <corpname>corp</corpname></unittitle><unitdate>3000</unitdate><sibling>b</sibling></parent>"
     )
     self.assertEquals(
         etree.tostring(move_unitdates(unittitle_input,
                                       "move_and_calcify")),
         etree.tostring(unittitle_target))
Ejemplo n.º 4
0
 def test_clean_with_extra_tags(self):
     ut_input = etree.fromstring(
         "<parent>{0}{4}text{5}, {1}1956{2}, and {1}1234{2}{3}</parent>".
         format("<unittitle>", "<unitdate>", "</unitdate>", "</unittitle>",
                "<extra>", "</extra>"))
     ut_input = ut_input.xpath("unittitle")[0]
     ut_target = etree.fromstring(
         "<parent>{0}{4}text{5}{3}{1}1956{2}{1}1234{2}</parent>".format(
             "<unittitle>", "<unitdate>", "</unitdate>", "</unittitle>",
             "<extra>", "</extra>"))
     self.assertEquals(
         etree.tostring(move_unitdates(ut_input, "move_and_clean")),
         etree.tostring(ut_target))