15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
from .. import bugtracker, errors, urlutils
18
from .. import bugtracker, urlutils
19
19
from . import TestCase, TestCaseWithMemoryTransport
22
class ErrorsTest(TestCaseWithMemoryTransport):
24
def test_unknown_bug_tracker_abbreviation(self):
25
"""Test the formatting of UnknownBugTrackerAbbreviation."""
26
branch = self.make_branch('some_branch')
27
error = bugtracker.UnknownBugTrackerAbbreviation('xxx', branch)
29
"Cannot find registered bug tracker called xxx on %s" % branch,
32
def test_malformed_bug_identifier(self):
33
"""Test the formatting of MalformedBugIdentifier."""
34
error = bugtracker.MalformedBugIdentifier(
35
'bogus', 'reason for bogosity')
37
'Did not understand bug identifier bogus: reason for bogosity. '
38
'See "brz help bugs" for more information on this feature.',
41
def test_incorrect_url(self):
42
err = bugtracker.InvalidBugTrackerURL('foo', 'http://bug.com/')
44
("The URL for bug tracker \"foo\" doesn't contain {id}: "
22
49
class TestGetBugURL(TestCaseWithMemoryTransport):
23
50
"""Tests for bugtracker.get_bug_url"""
54
81
def test_unrecognized_abbreviation_raises_error(self):
55
82
"""If the abbreviation is unrecognized, then raise an error."""
56
83
branch = self.make_branch('some_branch')
57
self.assertRaises(errors.UnknownBugTrackerAbbreviation,
84
self.assertRaises(bugtracker.UnknownBugTrackerAbbreviation,
58
85
bugtracker.get_bug_url, 'xxx', branch, '1234')
59
86
self.assertEqual([('get', 'xxx', branch)], self.tracker_type.log)
130
157
config = branch.get_config()
131
158
config.set_user_option('bugtracker_foo_url', 'http://bugs.com/view.html')
132
159
tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
133
self.assertRaises(errors.InvalidBugTrackerURL, tracker.get_bug_url, '1234')
160
self.assertRaises(bugtracker.InvalidBugTrackerURL, tracker.get_bug_url,
136
164
class TestUniqueIntegerBugTracker(TestCaseWithMemoryTransport):
179
207
tracker = bugtracker.UniqueIntegerBugTracker('xxx',
180
208
'http://bugs.com/')
181
209
self.assertRaises(
182
errors.MalformedBugIdentifier, tracker.check_bug_id, 'red')
210
bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
184
212
class TestURLParametrizedBugTracker(TestCaseWithMemoryTransport):
185
213
"""Tests for URLParametrizedBugTracker."""
230
258
should raise an error.
232
260
self.assertRaises(
233
errors.MalformedBugIdentifier, self.tracker.get_bug_url, 'bad')
261
bugtracker.MalformedBugIdentifier, self.tracker.get_bug_url, 'bad')
236
264
class TestPropertyEncoding(TestCase):