示例#1
0
    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>"))
示例#2
0
    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'>"))
示例#3
0
    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 &lt;b&gt;this&lt;/b&gt; out")))
示例#4
0
    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> &lt;disk&gt; &lt;driver name=\"...\"&gt; should be optional"
            )))