Skip to content

Commit

Permalink
Add 100% test coverage for bodhi.server.util.bug_link.
Browse files Browse the repository at this point in the history
Signed-off-by: Randy Barlow <[email protected]>
  • Loading branch information
bowlofeggs committed Aug 15, 2017
1 parent d52460e commit fb679ea
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions bodhi/tests/server/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright © 2007-2017 Red Hat, Inc. and others.
#
# This file is part of Bodhi.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
Expand All @@ -22,6 +27,48 @@
from bodhi.server.config import config


class TestBugLink(unittest.TestCase):
"""Tests for the bug_link() function."""
def test_short_false_with_title(self):
"""Test a call to bug_link() with short=False on a Bug that has a title."""
bug = mock.MagicMock()
bug.bug_id = 1234567
bug.title = "Lucky bug number"

link = util.bug_link(None, bug)

self.assertEqual(
link,
("<a target='_blank' href='https://bugzilla.redhat.com/show_bug.cgi?id=1234567'>"
"#1234567</a> Lucky bug number"))

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_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>"))


class TestUtils(unittest.TestCase):

def setUp(self):
Expand Down

0 comments on commit fb679ea

Please sign in to comment.