~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bugtracker.py

  • Committer: Martin Pool
  • Date: 2009-07-10 06:46:10 UTC
  • mto: (4525.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4526.
  • Revision ID: mbp@sourcefrog.net-20090710064610-sqviksbqp5i34sw2
Rename to per_interrepository

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007 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
41
41
        self.tracker_type = TestGetBugURL.TransientTracker
42
42
        self.tracker_type.log = []
43
43
        bugtracker.tracker_registry.register('transient', self.tracker_type)
44
 
        self.addCleanup(bugtracker.tracker_registry.remove, 'transient')
 
44
        self.addCleanup(lambda:
 
45
                        bugtracker.tracker_registry.remove('transient'))
45
46
 
46
47
    def test_get_bug_url_for_transient_tracker(self):
47
48
        branch = self.make_branch('some_branch')
117
118
        self.assertEqual('http://bugs.com/1234/view.html',
118
119
                         tracker.get_bug_url('1234'))
119
120
 
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
 
 
128
121
    def test_generic_incorrect_url(self):
129
122
        branch = self.make_branch('some_branch')
130
123
        config = branch.get_config()
181
174
        self.assertRaises(
182
175
            errors.MalformedBugIdentifier, tracker.check_bug_id, 'red')
183
176
 
184
 
class TestURLParametrizedBugTracker(TestCaseWithMemoryTransport):
185
 
    """Tests for URLParametrizedBugTracker."""
 
177
 
 
178
class TestURLParametrizedIntegerBugTracker(TestCaseWithMemoryTransport):
 
179
    """Tests for TracTracker."""
186
180
 
187
181
    def setUp(self):
188
182
        TestCaseWithMemoryTransport.setUp(self)
189
183
        self.url = 'http://twistedmatrix.com/trac'
190
 
        self.tracker = bugtracker.URLParametrizedBugTracker('some', 'ticket/')
 
184
        self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
 
185
                                                                   'ticket/')
191
186
 
192
187
    def test_get_with_unsupported_tag(self):
193
188
        """If asked for an unrecognized or unconfigured tag, return None."""
199
194
        """If asked for a valid tag, return a tracker instance that can map bug
200
195
        IDs to <base_url>/<bug_area> + <bug_id>."""
201
196
        bugtracker.tracker_registry.register('some', self.tracker)
202
 
        self.addCleanup(bugtracker.tracker_registry.remove, 'some')
 
197
        self.addCleanup(lambda: bugtracker.tracker_registry.remove('some'))
203
198
 
204
199
        branch = self.make_branch('some_branch')
205
200
        config = branch.get_config()
209
204
            urlutils.join(self.url, 'ticket/') + '1234',
210
205
            tracker.get_bug_url('1234'))
211
206
 
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
 
        TestCaseWithMemoryTransport.setUp(self)
224
 
        self.url = 'http://twistedmatrix.com/trac'
225
 
        self.tracker = bugtracker.URLParametrizedIntegerBugTracker('some',
226
 
                                                                   'ticket/')
227
 
 
228
207
    def test_get_bug_url_for_bad_bug(self):
229
208
        """When given a bug identifier that is invalid for Trac, get_bug_url
230
209
        should raise an error.