15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
18
from bzrlib import bugtracker
21
19
from bzrlib import errors
22
20
from bzrlib.tests import TestCaseWithMemoryTransport
167
165
bugtracker.TracTracker(self.trac_url).get_bug_url('1234'),
168
166
tracker.get_bug_url('1234'))
170
def test_get_bug_url_for_bad_bag(self):
171
"""When given a bug identifier that is invalid for Launchpad,
168
def test_get_bug_url_for_bad_bug(self):
169
"""When given a bug identifier that is invalid for Trac, get_bug_url
170
should raise an error.
172
tracker = bugtracker.TracTracker(self.trac_url)
174
errors.MalformedBugIdentifier, tracker.get_bug_url, 'bad')
177
class TestBugzillaTracker(TestCaseWithMemoryTransport):
178
"""Tests for BugzillaTracker."""
181
TestCaseWithMemoryTransport.setUp(self)
182
self.bugzilla_url = 'http://issues.apache.org/bugzilla'
184
def test_get_bug_url(self):
185
"""A BugzillaTracker should map a bug id to a URL for that instance."""
186
tracker = bugtracker.BugzillaTracker(self.bugzilla_url)
188
'%s/show_bug.cgi?id=1234' % self.bugzilla_url,
189
tracker.get_bug_url('1234'))
191
def test_get_with_unsupported_tag(self):
192
"""If asked for an unrecognized or unconfigured tag, return None."""
193
branch = self.make_branch('some_branch')
194
self.assertEqual(None, bugtracker.BugzillaTracker.get('lp', branch))
195
self.assertEqual(None,
196
bugtracker.BugzillaTracker.get('twisted', branch))
198
def test_get_with_supported_tag(self):
199
"""If asked for a valid tag, return a matching BugzillaTracker
202
branch = self.make_branch('some_branch')
203
config = branch.get_config()
204
config.set_user_option('bugzilla_apache_url', self.bugzilla_url)
205
tracker = bugtracker.BugzillaTracker.get('apache', branch)
207
bugtracker.BugzillaTracker(self.bugzilla_url).get_bug_url('1234'),
208
tracker.get_bug_url('1234'))
210
def test_get_bug_url_for_bad_bug(self):
211
"""When given a bug identifier that is invalid for Bugzilla,
172
212
get_bug_url should raise an error.
174
tracker = bugtracker.TracTracker(self.trac_url)
214
tracker = bugtracker.BugzillaTracker(self.bugzilla_url)
175
215
self.assertRaises(
176
216
errors.MalformedBugIdentifier, tracker.get_bug_url, 'bad')