def test_get_link_list_href(self): link1 = Link("http://example.com/", name="link1", title="title1") link2 = Link("http://example.com/", name="link2", title="title2") paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) # url elements = self.body.get_links(url=r"\.com") self.assertEqual(len(elements), 2)
def test_get_link_list(self): link1 = Link("http://example.com/", name="link1") link2 = Link("http://example.com/", name="link2") paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) element = self.body.get_links()[1] expected = '<text:a xlink:href="http://example.com/" ' 'office:name="link2"/>' self.assertEqual(element.serialize(), expected)
def test_get_link_list_not_found(self): link1 = Link("http://example.com/", name="link1", title="title1") link2 = Link("http://example.com/", name="link2", title="title2") paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) # Not found element = self.body.get_links(name="link1", title="title2") self.assertEqual(element, [])
def test_get_link_list_href(self): link1 = Link('http://example.com/', name='link1', title='title1') link2 = Link('http://example.com/', name='link2', title='title2') paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) # url elements = self.body.get_links(url=r'\.com') self.assertEqual(len(elements), 2)
def test_get_link_list_not_found(self): link1 = Link('http://example.com/', name='link1', title='title1') link2 = Link('http://example.com/', name='link2', title='title2') paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) # Not found element = self.body.get_links(name='link1', title='title2') self.assertEqual(element, [])
def test_get_link(self): link1 = Link('http://example.com/', name='link1') link2 = Link('http://example.com/', name='link2') paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) element = self.body.get_link(name='link2') expected = ('<text:a xlink:href="http://example.com/" ' 'office:name="link2"/>') self.assertEqual(element.serialize(), expected)
def test_get_link_list_title(self): link1 = Link('http://example.com/', name='link1', title='title1') link2 = Link('http://example.com/', name='link2', title='title2') paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) # title element = self.body.get_links(title='title2')[0] expected = ('<text:a xlink:href="http://example.com/" ' 'office:name="link2" office:title="title2"/>') self.assertEqual(element.serialize(), expected)
def test_create_link2(self): link = Link('http://example.com/', name='link2', target_frame='_blank', style='style1', visited_style='style2') expected = ('<text:a xlink:href="http://example.com/" ' 'office:name="link2" office:target-frame-name="_blank" ' 'xlink:show="new" text:style-name="style1" ' 'text:visited-style-name="style2"/>') self.assertEqual(link.serialize(), expected)
def test_get_link_list_name(self): link1 = Link("http://example.com/", name="link1", title="title1") link2 = Link("http://example.com/", name="link2", title="title2") paragraph = self.paragraph paragraph.append(link1) paragraph.append(link2) # name element = self.body.get_links(name="link1")[0] expected = ( '<text:a xlink:href="http://example.com/" ' 'office:name="link1" office:title="title1"/>' ) self.assertEqual(element.serialize(), expected)
def test_create_link1(self): link = Link("http://example.com/") expected = '<text:a xlink:href="http://example.com/"/>' self.assertEqual(link.serialize(), expected)