/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 brzlib/tests/test_bugtracker.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
from bzrlib import bugtracker, errors, urlutils
19
 
from bzrlib.tests import TestCase, TestCaseWithMemoryTransport
 
18
from brzlib import bugtracker, errors, urlutils
 
19
from brzlib.tests import TestCase, TestCaseWithMemoryTransport
20
20
 
21
21
 
22
22
class TestGetBugURL(TestCaseWithMemoryTransport):
37
37
            return "http://bugs.com/%s" % bug_id
38
38
 
39
39
    def setUp(self):
40
 
        TestCaseWithMemoryTransport.setUp(self)
 
40
        super(TestGetBugURL, self).setUp()
41
41
        self.tracker_type = TestGetBugURL.TransientTracker
42
42
        self.tracker_type.log = []
43
43
        bugtracker.tracker_registry.register('transient', self.tracker_type)
117
117
        self.assertEqual('http://bugs.com/1234/view.html',
118
118
                         tracker.get_bug_url('1234'))
119
119
 
 
120
    def test_generic_registered_non_integer(self):
 
121
        branch = self.make_branch('some_branch')
 
122
        config = branch.get_config()
 
123
        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/{id}/view.html')
 
124
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
 
125
        self.assertEqual('http://bugs.com/ABC-1234/view.html',
 
126
                         tracker.get_bug_url('ABC-1234'))
 
127
 
120
128
    def test_generic_incorrect_url(self):
121
129
        branch = self.make_branch('some_branch')
122
130
        config = branch.get_config()
173
181
        self.assertRaises(
174
182
            errors.MalformedBugIdentifier, tracker.check_bug_id, 'red')
175
183
 
176
 
 
177
 
class TestURLParametrizedIntegerBugTracker(TestCaseWithMemoryTransport):
178
 
    """Tests for TracTracker."""
 
184
class TestURLParametrizedBugTracker(TestCaseWithMemoryTransport):
 
185
    """Tests for URLParametrizedBugTracker."""
179
186
 
180
187
    def setUp(self):
181
 
        TestCaseWithMemoryTransport.setUp(self)
 
188
        super(TestURLParametrizedBugTracker, self).setUp()
182
189
        self.url = 'http://twistedmatrix.com/trac'
183
 
        self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
184
 
                                                                   'ticket/')
 
190
        self.tracker = bugtracker.URLParametrizedBugTracker('some', 'ticket/')
185
191
 
186
192
    def test_get_with_unsupported_tag(self):
187
193
        """If asked for an unrecognized or unconfigured tag, return None."""
203
209
            urlutils.join(self.url, 'ticket/') + '1234',
204
210
            tracker.get_bug_url('1234'))
205
211
 
 
212
    def test_get_bug_url_for_integer_id(self):
 
213
        self.tracker.check_bug_id('1234')
 
214
 
 
215
    def test_get_bug_url_for_non_integer_id(self):
 
216
        self.tracker.check_bug_id('ABC-1234')
 
217
 
 
218
 
 
219
class TestURLParametrizedIntegerBugTracker(TestCaseWithMemoryTransport):
 
220
    """Tests for URLParametrizedIntegerBugTracker."""
 
221
 
 
222
    def setUp(self):
 
223
        super(TestURLParametrizedIntegerBugTracker, self).setUp()
 
224
        self.url = 'http://twistedmatrix.com/trac'
 
225
        self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
 
226
                                                                   'ticket/')
 
227
 
206
228
    def test_get_bug_url_for_bad_bug(self):
207
229
        """When given a bug identifier that is invalid for Trac, get_bug_url
208
230
        should raise an error.