def test_single_anchor_with_cross_reference_as_anchored_text(self): # ARRANGE # root = Element('root') para = Paragraph([ core.AnchorText( core.CrossReferenceText( StringText('cross ref title'), CrossReferenceTargetTestImpl('cross ref target'), target_is_id_in_same_document=True), CrossReferenceTargetTestImpl('anchor target')), ]) # ACT # ret_val = sut.render(TextRenderer(TARGET_RENDERER), root, para, skip_surrounding_p_element=True) # ASSERT # xml_string = as_unicode_str(root) self.assertEqual( '<root>' '<span id="anchor target">' '<a href="#cross ref target">cross ref title</a>' '</span>' '</root>', xml_string) self.assertIs(root, ret_val)
def test_anchor(self): # ARRANGE # item = sut.AnchorText(sut.StringText('concrete string text'), sut.CrossReferenceTarget()) visitor = AVisitorThatRecordsClassForMethod() # ACT # ret_val = item.accept(visitor) # ASSERT # self.assertIs(ret_val, item) self.assertEqual(1, len(visitor.visited_class), 'number of methods') self.assertIs(sut.AnchorText, visitor.visited_class[0], 'method')
def test_single_anchor_with_string_as_anchored_text(self): # ARRANGE # root = Element('root') para = Paragraph([ core.AnchorText(core.StringText('concrete string'), CrossReferenceTargetTestImpl('target')), ]) # ACT # ret_val = sut.render(TextRenderer(TARGET_RENDERER), root, para) # ASSERT # xml_string = as_unicode_str(root) self.assertEqual( '<root>' '<p>' '<span id="target">concrete string</span>' '</p>' '</root>', xml_string) self._assert_first_child__of_actual_is_same_object_as(root, ret_val)
def test_single_anchor_with_string_as_anchored_text(self): # ARRANGE # root = Element('root') para = Paragraph([ core.AnchorText(core.StringText('concrete string'), CrossReferenceTargetTestImpl('target')), ]) # ACT # ret_val = sut.render(TextRenderer(TARGET_RENDERER), root, para, skip_surrounding_p_element=True) # ASSERT # xml_string = as_unicode_str(root) self.assertEqual( '<root>' '<span id="target">concrete string</span>' '</root>', xml_string) self.assertIs(root, ret_val)