def test_short_true(self): """Test a call to bug_link() with short=True.""" bug = mock.MagicMock() bug.bug_id = 1234567 bug.title = "Lucky bug number" link = util.bug_link(None, bug, True) self.assertEqual(link, ( "<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1234567'>" "#1234567</a>"))
def test_short_false_without_title(self): """Test a call to bug_link() with short=False on a Bug that has no title.""" bug = mock.MagicMock() bug.bug_id = 1234567 bug.title = None link = util.bug_link(None, bug) self.assertEqual(link, ( "<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1234567'>" "#1234567</a> <img class='spinner' src='static/img/spinner.gif'>"))
def test_short_false_with_title_sanitizes_safe_tags(self): """ Test that a call to bug_link() with short=False on a Bug that has a title sanitizes even safe tags because really they should be rendered human readable. """ bug = mock.MagicMock() bug.bug_id = 1234567 bug.title = 'Check <b>this</b> out' link = util.bug_link(None, bug) self.assertTrue( link.startswith(( "<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1234567'>" "#1234567</a> Check <b>this</b> out")))
def test_short_false_with_title_sanitizes_unsafe_tags(self): """ Test that a call to bug_link() with short=False on a Bug that has a title sanitizes unsafe tags. """ bug = mock.MagicMock() bug.bug_id = 1473091 bug.title = '<disk> <driver name="..."> should be optional' link = util.bug_link(None, bug) self.assertTrue( link.startswith(( "<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1473091'>" "#1473091</a> <disk> <driver name=\"...\"> should be optional" )))