Ejemplo n.º 1
0
 def test_two_string_text(self):
     # ARRANGE #
     root = Element('root')
     para = Paragraph([core.StringText('_1_'), core.StringText('_2_')])
     # ACT #
     ret_val = sut.render(TextRenderer(TARGET_RENDERER), root, para)
     # ASSERT #
     xml_string = as_unicode_str(root)
     self.assertEqual('<root>' '<p>_1_<br />_2_</p>' '</root>', xml_string)
     self._assert_first_child__of_actual_is_same_object_as(root, ret_val)
Ejemplo n.º 2
0
 def test_two_string_text(self):
     # ARRANGE #
     root = Element('root')
     para = Paragraph([core.StringText('_1_'), core.StringText('_2_')])
     # 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>' '_1_<br />_2_' '</root>', xml_string)
     self.assertIs(root, ret_val)
Ejemplo n.º 3
0
 def test_visit_string(self):
     # ARRANGE #
     item = sut.StringText('string text')
     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.StringText, visitor.visited_class[0], 'method')
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
 def test_visit_list(self):
     # ARRANGE #
     list_item = lists.HeaderContentListItem(core.StringText('item text'),
                                             [])
     item = lists.HeaderContentList([list_item],
                                    lists.Format(
                                        lists.ListType.ITEMIZED_LIST))
     visitor = AVisitorThatRecordsVisitedMethods()
     # ACT #
     ret_val = visitor.visit(item)
     # ASSERT #
     self.assertEqual([lists.HeaderContentList], visitor.visited_types)
     self.assertIs(item, ret_val)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 def test_cross_reference_and_string(self):
     # ARRANGE #
     root = Element('root')
     para = Paragraph([
         core.CrossReferenceText(StringText('title'),
                                 CrossReferenceTargetTestImpl('target'),
                                 target_is_id_in_same_document=True),
         core.StringText('string')
     ])
     # ACT #
     ret_val = sut.render(TextRenderer(TARGET_RENDERER), root, para)
     # ASSERT #
     xml_string = as_unicode_str(root)
     self.assertEqual(
         '<root>'
         '<p>'
         '<a href="#target">title</a><br />string'
         '</p>'
         '</root>', xml_string)
     self._assert_first_child__of_actual_is_same_object_as(root, ret_val)
Ejemplo n.º 9
0
def _section_iff_has_paragraphs(
        header: str,
        paragraphs: Sequence[ParagraphItem]) -> Sequence[SectionItem]:
    return ((document.Section(core.StringText(header),
                              document.SectionContents(list(paragraphs))), )
            if paragraphs else ())
Ejemplo n.º 10
0
def text(string: str) -> core.Text:
    return core.StringText(string)
Ejemplo n.º 11
0
 def sub(self, presentation: str, local_target_name: str) -> TargetInfo:
     return self.sub_factory(local_target_name).root(
         core.StringText(presentation))