/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

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
    def test_generic_registered(self):
146
146
        branch = self.make_branch('some_branch')
147
147
        config = branch.get_config()
148
 
        config.set_user_option('bugtracker_foo_url',
149
 
                               'http://bugs.example.com/{id}/view.html')
 
148
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/{id}/view.html')
150
149
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
151
150
        self.assertEqual('http://bugs.example.com/1234/view.html',
152
151
                         tracker.get_bug_url('1234'))
154
153
    def test_generic_registered_non_integer(self):
155
154
        branch = self.make_branch('some_branch')
156
155
        config = branch.get_config()
157
 
        config.set_user_option('bugtracker_foo_url',
158
 
                               'http://bugs.example.com/{id}/view.html')
 
156
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/{id}/view.html')
159
157
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
160
158
        self.assertEqual('http://bugs.example.com/ABC-1234/view.html',
161
159
                         tracker.get_bug_url('ABC-1234'))
163
161
    def test_generic_incorrect_url(self):
164
162
        branch = self.make_branch('some_branch')
165
163
        config = branch.get_config()
166
 
        config.set_user_option('bugtracker_foo_url',
167
 
                               'http://bugs.example.com/view.html')
 
164
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/view.html')
168
165
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
169
166
        self.assertRaises(bugtracker.InvalidBugTrackerURL, tracker.get_bug_url,
170
 
                          '1234')
 
167
                '1234')
171
168
 
172
169
 
173
170
class TestUniqueIntegerBugTracker(TestCaseWithMemoryTransport):
175
172
    def test_appends_id_to_base_url(self):
176
173
        """The URL of a bug is the base URL joined to the identifier."""
177
174
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
178
 
                                                     'http://bugs.example.com/foo')
179
 
        self.assertEqual('http://bugs.example.com/foo1234',
180
 
                         tracker.get_bug_url('1234'))
 
175
                'http://bugs.example.com/foo')
 
176
        self.assertEqual('http://bugs.example.com/foo1234', tracker.get_bug_url('1234'))
181
177
 
182
178
    def test_returns_tracker_if_abbreviation_matches(self):
183
179
        """The get() method should return an instance of the tracker if the
184
180
        given abbreviation matches the tracker's abbreviated name.
185
181
        """
186
182
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
187
 
                                                     'http://bugs.example.com/')
 
183
                'http://bugs.example.com/')
188
184
        branch = self.make_branch('some_branch')
189
185
        self.assertIs(tracker, tracker.get('xxx', branch))
190
186
 
193
189
        doesn't match the tracker's abbreviation.
194
190
        """
195
191
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
196
 
                                                     'http://bugs.example.com/')
 
192
                'http://bugs.example.com/')
197
193
        branch = self.make_branch('some_branch')
198
194
        self.assertIs(None, tracker.get('yyy', branch))
199
195
 
202
198
        information.
203
199
        """
204
200
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
205
 
                                                     'http://bugs.example.com/')
 
201
                'http://bugs.example.com/')
206
202
        self.assertIs(tracker, tracker.get('xxx', None))
207
203
        self.assertIs(None, tracker.get('yyy', None))
208
204
 
209
205
    def test_check_bug_id_only_accepts_integers(self):
210
206
        """A UniqueIntegerBugTracker accepts integers as bug IDs."""
211
207
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
212
 
                                                     'http://bugs.example.com/')
 
208
                'http://bugs.example.com/')
213
209
        tracker.check_bug_id('1234')
214
210
 
215
211
    def test_check_bug_id_doesnt_accept_non_integers(self):
216
212
        """A UniqueIntegerBugTracker rejects non-integers as bug IDs."""
217
213
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
218
 
                                                     'http://bugs.example.com/')
 
214
                'http://bugs.example.com/')
219
215
        self.assertRaises(
220
216
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
221
217
 
225
221
    def test_appends_id_to_base_url(self):
226
222
        """The URL of a bug is the base URL joined to the identifier."""
227
223
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
228
 
                                                      'http://bugs.example.com/{project}/{id}')
229
 
        self.assertEqual('http://bugs.example.com/foo/1234',
230
 
                         tracker.get_bug_url('foo/1234'))
 
224
                'http://bugs.example.com/{project}/{id}')
 
225
        self.assertEqual('http://bugs.example.com/foo/1234', tracker.get_bug_url('foo/1234'))
231
226
 
232
227
    def test_returns_tracker_if_abbreviation_matches(self):
233
228
        """The get() method should return an instance of the tracker if the
234
229
        given abbreviation matches the tracker's abbreviated name.
235
230
        """
236
231
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
237
 
                                                      'http://bugs.example.com/{project}/{id}')
 
232
                'http://bugs.example.com/{project}/{id}')
238
233
        branch = self.make_branch('some_branch')
239
234
        self.assertIs(tracker, tracker.get('xxx', branch))
240
235
 
243
238
        doesn't match the tracker's abbreviation.
244
239
        """
245
240
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
246
 
                                                      'http://bugs.example.com/{project}/{id}')
 
241
                'http://bugs.example.com/{project}/{id}')
247
242
        branch = self.make_branch('some_branch')
248
243
        self.assertIs(None, tracker.get('yyy', branch))
249
244
 
251
246
        """Shouldn't consult the branch for tracker information.
252
247
        """
253
248
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
254
 
                                                      'http://bugs.example.com/{project}/{id}')
 
249
                'http://bugs.example.com/{project}/{id}')
255
250
        self.assertIs(tracker, tracker.get('xxx', None))
256
251
        self.assertIs(None, tracker.get('yyy', None))
257
252
 
258
253
    def test_check_bug_id_only_accepts_project_integers(self):
259
254
        """Accepts integers as bug IDs."""
260
255
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
261
 
                                                      'http://bugs.example.com/{project}/{id}')
 
256
                'http://bugs.example.com/{project}/{id}')
262
257
        tracker.check_bug_id('project/1234')
263
258
 
264
259
    def test_check_bug_id_doesnt_accept_non_project_integers(self):
265
260
        """Rejects non-integers as bug IDs."""
266
261
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
267
 
                                                      'http://bugs.example.com/{project}/{id}')
 
262
                'http://bugs.example.com/{project}/{id}')
268
263
        self.assertRaises(
269
264
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
270
265
        self.assertRaises(
329
324
    def test_encoding_one(self):
330
325
        self.assertEqual(
331
326
            'http://example.com/bugs/1 fixed',
332
 
            bugtracker.encode_fixes_bug_urls(
333
 
                [('http://example.com/bugs/1', 'fixed')]))
 
327
            bugtracker.encode_fixes_bug_urls(['http://example.com/bugs/1']))
334
328
 
335
329
    def test_encoding_zero(self):
336
330
        self.assertEqual('', bugtracker.encode_fixes_bug_urls([]))
338
332
    def test_encoding_two(self):
339
333
        self.assertEqual(
340
334
            'http://example.com/bugs/1 fixed\n'
341
 
            'http://example.com/bugs/2 related',
 
335
            'http://example.com/bugs/2 fixed',
342
336
            bugtracker.encode_fixes_bug_urls(
343
 
                [('http://example.com/bugs/1', 'fixed'),
344
 
                 ('http://example.com/bugs/2', 'related')]))
345
 
 
346
 
    def test_encoding_with_space(self):
347
 
        self.assertRaises(
348
 
            bugtracker.InvalidBugUrl,
349
 
            bugtracker.encode_fixes_bug_urls,
350
 
            [('http://example.com/bugs/ 1', 'fixed')])
351
 
 
352
 
 
353
 
class TestPropertyDecoding(TestCase):
354
 
    """Tests for parsing bug revision properties."""
355
 
 
356
 
    def test_decoding_one(self):
357
 
        self.assertEqual(
358
 
            [('http://example.com/bugs/1', 'fixed')],
359
 
            list(bugtracker.decode_bug_urls(
360
 
                'http://example.com/bugs/1 fixed')))
361
 
 
362
 
    def test_decoding_zero(self):
363
 
        self.assertEqual([], list(bugtracker.decode_bug_urls('')))
364
 
 
365
 
    def test_decoding_two(self):
366
 
        self.assertEqual(
367
 
            [('http://example.com/bugs/1', 'fixed'),
368
 
             ('http://example.com/bugs/2', 'related')],
369
 
            list(bugtracker.decode_bug_urls(
370
 
                'http://example.com/bugs/1 fixed\n'
371
 
                'http://example.com/bugs/2 related')))
372
 
 
373
 
    def test_decoding_invalid(self):
374
 
        self.assertRaises(
375
 
            bugtracker.InvalidLineInBugsProperty,
376
 
            list,
377
 
            bugtracker.decode_bug_urls('http://example.com/bugs/ 1 fixed\n'))
 
337
                ['http://example.com/bugs/1', 'http://example.com/bugs/2']))