/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: Martin
  • Date: 2018-11-16 19:09:31 UTC
  • mfrom: (7175 work)
  • mto: This revision was merged to the branch mainline in revision 7177.
  • Revision ID: gzlist@googlemail.com-20181116190931-rmh7pk2an1zuecby
Merge trunk to resolve conflicts

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', 'http://bugs.example.com/{id}/view.html')
 
148
        config.set_user_option('bugtracker_foo_url',
 
149
                               'http://bugs.example.com/{id}/view.html')
149
150
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
150
151
        self.assertEqual('http://bugs.example.com/1234/view.html',
151
152
                         tracker.get_bug_url('1234'))
153
154
    def test_generic_registered_non_integer(self):
154
155
        branch = self.make_branch('some_branch')
155
156
        config = branch.get_config()
156
 
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/{id}/view.html')
 
157
        config.set_user_option('bugtracker_foo_url',
 
158
                               'http://bugs.example.com/{id}/view.html')
157
159
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
158
160
        self.assertEqual('http://bugs.example.com/ABC-1234/view.html',
159
161
                         tracker.get_bug_url('ABC-1234'))
161
163
    def test_generic_incorrect_url(self):
162
164
        branch = self.make_branch('some_branch')
163
165
        config = branch.get_config()
164
 
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/view.html')
 
166
        config.set_user_option('bugtracker_foo_url',
 
167
                               'http://bugs.example.com/view.html')
165
168
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
166
169
        self.assertRaises(bugtracker.InvalidBugTrackerURL, tracker.get_bug_url,
167
 
                '1234')
 
170
                          '1234')
168
171
 
169
172
 
170
173
class TestUniqueIntegerBugTracker(TestCaseWithMemoryTransport):
172
175
    def test_appends_id_to_base_url(self):
173
176
        """The URL of a bug is the base URL joined to the identifier."""
174
177
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
175
 
                'http://bugs.example.com/foo')
176
 
        self.assertEqual('http://bugs.example.com/foo1234', tracker.get_bug_url('1234'))
 
178
                                                     'http://bugs.example.com/foo')
 
179
        self.assertEqual('http://bugs.example.com/foo1234',
 
180
                         tracker.get_bug_url('1234'))
177
181
 
178
182
    def test_returns_tracker_if_abbreviation_matches(self):
179
183
        """The get() method should return an instance of the tracker if the
180
184
        given abbreviation matches the tracker's abbreviated name.
181
185
        """
182
186
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
183
 
                'http://bugs.example.com/')
 
187
                                                     'http://bugs.example.com/')
184
188
        branch = self.make_branch('some_branch')
185
189
        self.assertIs(tracker, tracker.get('xxx', branch))
186
190
 
189
193
        doesn't match the tracker's abbreviation.
190
194
        """
191
195
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
192
 
                'http://bugs.example.com/')
 
196
                                                     'http://bugs.example.com/')
193
197
        branch = self.make_branch('some_branch')
194
198
        self.assertIs(None, tracker.get('yyy', branch))
195
199
 
198
202
        information.
199
203
        """
200
204
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
201
 
                'http://bugs.example.com/')
 
205
                                                     'http://bugs.example.com/')
202
206
        self.assertIs(tracker, tracker.get('xxx', None))
203
207
        self.assertIs(None, tracker.get('yyy', None))
204
208
 
205
209
    def test_check_bug_id_only_accepts_integers(self):
206
210
        """A UniqueIntegerBugTracker accepts integers as bug IDs."""
207
211
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
208
 
                'http://bugs.example.com/')
 
212
                                                     'http://bugs.example.com/')
209
213
        tracker.check_bug_id('1234')
210
214
 
211
215
    def test_check_bug_id_doesnt_accept_non_integers(self):
212
216
        """A UniqueIntegerBugTracker rejects non-integers as bug IDs."""
213
217
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
214
 
                'http://bugs.example.com/')
 
218
                                                     'http://bugs.example.com/')
215
219
        self.assertRaises(
216
220
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
217
221
 
221
225
    def test_appends_id_to_base_url(self):
222
226
        """The URL of a bug is the base URL joined to the identifier."""
223
227
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
224
 
                'http://bugs.example.com/{project}/{id}')
225
 
        self.assertEqual('http://bugs.example.com/foo/1234', tracker.get_bug_url('foo/1234'))
 
228
                                                      'http://bugs.example.com/{project}/{id}')
 
229
        self.assertEqual('http://bugs.example.com/foo/1234',
 
230
                         tracker.get_bug_url('foo/1234'))
226
231
 
227
232
    def test_returns_tracker_if_abbreviation_matches(self):
228
233
        """The get() method should return an instance of the tracker if the
229
234
        given abbreviation matches the tracker's abbreviated name.
230
235
        """
231
236
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
232
 
                'http://bugs.example.com/{project}/{id}')
 
237
                                                      'http://bugs.example.com/{project}/{id}')
233
238
        branch = self.make_branch('some_branch')
234
239
        self.assertIs(tracker, tracker.get('xxx', branch))
235
240
 
238
243
        doesn't match the tracker's abbreviation.
239
244
        """
240
245
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
241
 
                'http://bugs.example.com/{project}/{id}')
 
246
                                                      'http://bugs.example.com/{project}/{id}')
242
247
        branch = self.make_branch('some_branch')
243
248
        self.assertIs(None, tracker.get('yyy', branch))
244
249
 
246
251
        """Shouldn't consult the branch for tracker information.
247
252
        """
248
253
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
249
 
                'http://bugs.example.com/{project}/{id}')
 
254
                                                      'http://bugs.example.com/{project}/{id}')
250
255
        self.assertIs(tracker, tracker.get('xxx', None))
251
256
        self.assertIs(None, tracker.get('yyy', None))
252
257
 
253
258
    def test_check_bug_id_only_accepts_project_integers(self):
254
259
        """Accepts integers as bug IDs."""
255
260
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
256
 
                'http://bugs.example.com/{project}/{id}')
 
261
                                                      'http://bugs.example.com/{project}/{id}')
257
262
        tracker.check_bug_id('project/1234')
258
263
 
259
264
    def test_check_bug_id_doesnt_accept_non_project_integers(self):
260
265
        """Rejects non-integers as bug IDs."""
261
266
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
262
 
                'http://bugs.example.com/{project}/{id}')
 
267
                                                      'http://bugs.example.com/{project}/{id}')
263
268
        self.assertRaises(
264
269
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
265
270
        self.assertRaises(