/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_bugtracker.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
from .. import bugtracker, errors, urlutils
 
18
from .. import bugtracker, urlutils
19
19
from . import TestCase, TestCaseWithMemoryTransport
20
20
 
21
21
 
 
22
class ErrorsTest(TestCaseWithMemoryTransport):
 
23
 
 
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)
 
28
        self.assertEqual(
 
29
            "Cannot find registered bug tracker called xxx on %s" % branch,
 
30
            str(error))
 
31
 
 
32
    def test_malformed_bug_identifier(self):
 
33
        """Test the formatting of MalformedBugIdentifier."""
 
34
        error = bugtracker.MalformedBugIdentifier(
 
35
            'bogus', 'reason for bogosity')
 
36
        self.assertEqual(
 
37
            'Did not understand bug identifier bogus: reason for bogosity. '
 
38
            'See "brz help bugs" for more information on this feature.',
 
39
            str(error))
 
40
 
 
41
    def test_incorrect_url(self):
 
42
        err = bugtracker.InvalidBugTrackerURL('foo', 'http://bug.com/')
 
43
        self.assertEqual(
 
44
            ("The URL for bug tracker \"foo\" doesn't contain {id}: "
 
45
             "http://bug.com/"),
 
46
            str(err))
 
47
 
 
48
 
22
49
class TestGetBugURL(TestCaseWithMemoryTransport):
23
50
    """Tests for bugtracker.get_bug_url"""
24
51
 
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)
60
87
 
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,
 
161
                '1234')
134
162
 
135
163
 
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')
183
211
 
184
212
class TestURLParametrizedBugTracker(TestCaseWithMemoryTransport):
185
213
    """Tests for URLParametrizedBugTracker."""
230
258
        should raise an error.
231
259
        """
232
260
        self.assertRaises(
233
 
            errors.MalformedBugIdentifier, self.tracker.get_bug_url, 'bad')
 
261
            bugtracker.MalformedBugIdentifier, self.tracker.get_bug_url, 'bad')
234
262
 
235
263
 
236
264
class TestPropertyEncoding(TestCase):