156
155
TestCaseWithMemoryTransport.setUp(self)
157
156
self.url = 'http://twistedmatrix.com/trac'
157
self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
159
160
def test_get_with_unsupported_tag(self):
160
161
"""If asked for an unrecognized or unconfigured tag, return None."""
161
162
branch = self.make_branch('some_branch')
164
bugtracker.URLParametrizedIntegerBugTracker.get('lp', branch))
167
bugtracker.URLParametrizedIntegerBugTracker.get('twisted', branch))
163
self.assertEqual(None, self.tracker.get('lp', branch))
164
self.assertEqual(None, self.tracker.get('twisted', branch))
169
166
def test_get_with_supported_tag(self):
170
"""If asked for a valid tag, return a matching tracker instance."""
171
class SomeTracker(bugtracker.URLParametrizedIntegerBugTracker):
174
def _get_bug_url(self, bug_id):
175
return self._base_url + bug_id
167
"""If asked for a valid tag, return a tracker instance that can map bug
168
IDs to <base_url>/<bug_area> + <bug_id>."""
169
bugtracker.tracker_registry.register('some', self.tracker)
170
self.addCleanup(lambda: bugtracker.tracker_registry.remove('some'))
177
172
branch = self.make_branch('some_branch')
178
173
config = branch.get_config()
179
174
config.set_user_option('some_twisted_url', self.url)
180
tracker = SomeTracker.get('twisted', branch)
181
self.assertEqual(tracker.get_bug_url('1234'), self.url + '1234')
175
tracker = self.tracker.get('twisted', branch)
177
urlutils.join(self.url, 'ticket/') + '1234',
178
tracker.get_bug_url('1234'))
183
180
def test_get_bug_url_for_bad_bug(self):
184
181
"""When given a bug identifier that is invalid for Trac, get_bug_url
185
182
should raise an error.
187
tracker = bugtracker.URLParametrizedIntegerBugTracker(self.url)
188
184
self.assertRaises(
189
errors.MalformedBugIdentifier, tracker.get_bug_url, 'bad')
192
class TestTracTracker(TestCaseWithMemoryTransport):
193
"""Tests for TracTracker."""
195
def test_get_bug_url(self):
196
"""A URLParametrizedIntegerBugTracker should map a Trac bug to a URL
199
url = 'http://twistedmatrix.com/trac'
200
tracker = bugtracker.TracTracker(url)
201
self.assertEqual('%s/ticket/1234' % url, tracker.get_bug_url('1234'))
204
class TestBugzillaTracker(TestCaseWithMemoryTransport):
205
"""Tests for BugzillaTracker."""
208
TestCaseWithMemoryTransport.setUp(self)
210
def test_get_bug_url(self):
211
"""A BugzillaTracker should map a bug id to a URL for that instance."""
212
bugzilla_url = 'http://www.squid-cache.org/bugs'
213
tracker = bugtracker.BugzillaTracker(bugzilla_url)
215
'%s/show_bug.cgi?id=1234' % bugzilla_url,
216
tracker.get_bug_url('1234'))
185
errors.MalformedBugIdentifier, self.tracker.get_bug_url, 'bad')