|
44 | 44 |
|
45 | 45 | class MockDatabase(MockNull): |
46 | 46 | def getclass(self, name): |
| 47 | + # Class returned must have hasnode(id) method that returns true |
| 48 | + # otherwise designators like 'issue1' can't be hyperlinked. |
| 49 | + self.classes[name].hasnode = lambda id: True |
47 | 50 | return self.classes[name] |
48 | 51 |
|
49 | 52 | # setup for csrf testing of otks database api |
@@ -468,6 +471,34 @@ def test_string_markdown_link(self): |
468 | 471 | p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A link <http://localhost>')) |
469 | 472 | self.assertEqual(p.markdown().strip(), u2s(u'<p>A link <a href="http://localhost">http://localhost</a></p>')) |
470 | 473 |
|
| 474 | + def test_string_markdown_link_item(self): |
| 475 | + """ The link formats for the different markdown engines changes. |
| 476 | + Order of attributes, value for rel (noopener, nofollow etc) |
| 477 | + is different. So most tests check for a substring that indicates |
| 478 | + success rather than the entire returned string. |
| 479 | + """ |
| 480 | + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'An issue1 link')) |
| 481 | + self.assertIn( u2s(u'href="issue1"'), p.markdown().strip()) |
| 482 | + # just verify that plain linking is working |
| 483 | + self.assertIn( u2s(u'href="issue1"'), p.plain(hyperlink=1)) |
| 484 | + |
| 485 | + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'An [issue1](issue1) link')) |
| 486 | + self.assertIn( u2s(u'href="issue1"'), p.markdown().strip()) |
| 487 | + # just verify that plain linking is working |
| 488 | + self.assertIn( u2s(u'href="issue1"'), p.plain(hyperlink=1)) |
| 489 | + |
| 490 | + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'An [issue1](https://example.com/issue1) link')) |
| 491 | + self.assertIn( u2s(u'href="https://example.com/issue1"'), p.markdown().strip()) |
| 492 | + |
| 493 | + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'An [issue1] (https://example.com/issue1) link')) |
| 494 | + self.assertIn( u2s(u'href="issue1"'), p.markdown().strip()) |
| 495 | + if type(self) == MistuneTestCase: |
| 496 | + # mistune makes the https url into a real link |
| 497 | + self.assertIn( u2s(u'href="https://example.com/issue1"'), p.markdown().strip()) |
| 498 | + else: |
| 499 | + # the other two engines leave the parenthesized url as is. |
| 500 | + self.assertIn( u2s(u' (https://example.com/issue1) link'), p.markdown().strip()) |
| 501 | + |
471 | 502 | def test_string_markdown_link(self): |
472 | 503 | # markdown2 and markdown escape the email address |
473 | 504 | try: |
|
0 commit comments