/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: 2018-11-06 01:18:08 UTC
  • mfrom: (7143 work)
  • mto: This revision was merged to the branch mainline in revision 7151.
  • Revision ID: jelmer@jelmer.uk-20181106011808-y870f4vq0ork3ahu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
            str(error))
40
40
 
41
41
    def test_incorrect_url(self):
42
 
        err = bugtracker.InvalidBugTrackerURL('foo', 'http://bug.com/')
 
42
        err = bugtracker.InvalidBugTrackerURL('foo', 'http://bug.example.com/')
43
43
        self.assertEqual(
44
44
            ("The URL for bug tracker \"foo\" doesn't contain {id}: "
45
 
             "http://bug.com/"),
 
45
             "http://bug.example.com/"),
46
46
            str(err))
47
47
 
48
48
 
61
61
 
62
62
        def get_bug_url(self, bug_id):
63
63
            self.log.append(('get_bug_url', bug_id))
64
 
            return "http://bugs.com/%s" % bug_id
 
64
            return "http://bugs.example.com/%s" % bug_id
65
65
 
66
66
    def setUp(self):
67
67
        super(TestGetBugURL, self).setUp()
72
72
 
73
73
    def test_get_bug_url_for_transient_tracker(self):
74
74
        branch = self.make_branch('some_branch')
75
 
        self.assertEqual('http://bugs.com/1234',
 
75
        self.assertEqual('http://bugs.example.com/1234',
76
76
                         bugtracker.get_bug_url('transient', branch, '1234'))
77
77
        self.assertEqual(
78
78
            [('get', 'transient', branch), ('get_bug_url', '1234')],
119
119
        """
120
120
        branch = self.make_branch('some_branch')
121
121
        config = branch.get_config()
122
 
        config.set_user_option('trac_foo_url', 'http://bugs.com/trac')
 
122
        config.set_user_option('trac_foo_url', 'http://bugs.example.com/trac')
123
123
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
124
 
        self.assertEqual('http://bugs.com/trac/ticket/1234',
 
124
        self.assertEqual('http://bugs.example.com/trac/ticket/1234',
125
125
                         tracker.get_bug_url('1234'))
126
126
 
127
127
    def test_bugzilla_registered(self):
131
131
        """
132
132
        branch = self.make_branch('some_branch')
133
133
        config = branch.get_config()
134
 
        config.set_user_option('bugzilla_foo_url', 'http://bugs.com')
 
134
        config.set_user_option('bugzilla_foo_url', 'http://bugs.example.com')
135
135
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
136
 
        self.assertEqual('http://bugs.com/show_bug.cgi?id=1234',
 
136
        self.assertEqual('http://bugs.example.com/show_bug.cgi?id=1234',
137
137
                         tracker.get_bug_url('1234'))
138
138
 
 
139
    def test_github(self):
 
140
        branch = self.make_branch('some_branch')
 
141
        tracker = bugtracker.tracker_registry.get_tracker('github', branch)
 
142
        self.assertEqual('https://github.com/breezy-team/breezy/issues/1234',
 
143
                         tracker.get_bug_url('breezy-team/breezy/1234'))
 
144
 
139
145
    def test_generic_registered(self):
140
146
        branch = self.make_branch('some_branch')
141
147
        config = branch.get_config()
142
 
        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/{id}/view.html')
 
148
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/{id}/view.html')
143
149
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
144
 
        self.assertEqual('http://bugs.com/1234/view.html',
 
150
        self.assertEqual('http://bugs.example.com/1234/view.html',
145
151
                         tracker.get_bug_url('1234'))
146
152
 
147
153
    def test_generic_registered_non_integer(self):
148
154
        branch = self.make_branch('some_branch')
149
155
        config = branch.get_config()
150
 
        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/{id}/view.html')
 
156
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/{id}/view.html')
151
157
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
152
 
        self.assertEqual('http://bugs.com/ABC-1234/view.html',
 
158
        self.assertEqual('http://bugs.example.com/ABC-1234/view.html',
153
159
                         tracker.get_bug_url('ABC-1234'))
154
160
 
155
161
    def test_generic_incorrect_url(self):
156
162
        branch = self.make_branch('some_branch')
157
163
        config = branch.get_config()
158
 
        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/view.html')
 
164
        config.set_user_option('bugtracker_foo_url', 'http://bugs.example.com/view.html')
159
165
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
160
166
        self.assertRaises(bugtracker.InvalidBugTrackerURL, tracker.get_bug_url,
161
167
                '1234')
166
172
    def test_appends_id_to_base_url(self):
167
173
        """The URL of a bug is the base URL joined to the identifier."""
168
174
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
169
 
                'http://bugs.com/foo')
170
 
        self.assertEqual('http://bugs.com/foo1234', tracker.get_bug_url('1234'))
 
175
                'http://bugs.example.com/foo')
 
176
        self.assertEqual('http://bugs.example.com/foo1234', tracker.get_bug_url('1234'))
171
177
 
172
178
    def test_returns_tracker_if_abbreviation_matches(self):
173
179
        """The get() method should return an instance of the tracker if the
174
180
        given abbreviation matches the tracker's abbreviated name.
175
181
        """
176
182
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
177
 
                'http://bugs.com/')
 
183
                'http://bugs.example.com/')
178
184
        branch = self.make_branch('some_branch')
179
185
        self.assertIs(tracker, tracker.get('xxx', branch))
180
186
 
183
189
        doesn't match the tracker's abbreviation.
184
190
        """
185
191
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
186
 
                'http://bugs.com/')
 
192
                'http://bugs.example.com/')
187
193
        branch = self.make_branch('some_branch')
188
194
        self.assertIs(None, tracker.get('yyy', branch))
189
195
 
192
198
        information.
193
199
        """
194
200
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
195
 
                'http://bugs.com/')
 
201
                'http://bugs.example.com/')
196
202
        self.assertIs(tracker, tracker.get('xxx', None))
197
203
        self.assertIs(None, tracker.get('yyy', None))
198
204
 
199
205
    def test_check_bug_id_only_accepts_integers(self):
200
206
        """A UniqueIntegerBugTracker accepts integers as bug IDs."""
201
207
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
202
 
                'http://bugs.com/')
 
208
                'http://bugs.example.com/')
203
209
        tracker.check_bug_id('1234')
204
210
 
205
211
    def test_check_bug_id_doesnt_accept_non_integers(self):
206
212
        """A UniqueIntegerBugTracker rejects non-integers as bug IDs."""
207
213
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
208
 
                'http://bugs.com/')
209
 
        self.assertRaises(
210
 
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
 
214
                'http://bugs.example.com/')
 
215
        self.assertRaises(
 
216
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
 
217
 
 
218
 
 
219
class TestProjectIntegerBugTracker(TestCaseWithMemoryTransport):
 
220
 
 
221
    def test_appends_id_to_base_url(self):
 
222
        """The URL of a bug is the base URL joined to the identifier."""
 
223
        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'))
 
226
 
 
227
    def test_returns_tracker_if_abbreviation_matches(self):
 
228
        """The get() method should return an instance of the tracker if the
 
229
        given abbreviation matches the tracker's abbreviated name.
 
230
        """
 
231
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
 
232
                'http://bugs.example.com/{project}/{id}')
 
233
        branch = self.make_branch('some_branch')
 
234
        self.assertIs(tracker, tracker.get('xxx', branch))
 
235
 
 
236
    def test_returns_none_if_abbreviation_doesnt_match(self):
 
237
        """The get() method should return None if the given abbreviated name
 
238
        doesn't match the tracker's abbreviation.
 
239
        """
 
240
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
 
241
                'http://bugs.example.com/{project}/{id}')
 
242
        branch = self.make_branch('some_branch')
 
243
        self.assertIs(None, tracker.get('yyy', branch))
 
244
 
 
245
    def test_doesnt_consult_branch(self):
 
246
        """Shouldn't consult the branch for tracker information.
 
247
        """
 
248
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
 
249
                'http://bugs.example.com/{project}/{id}')
 
250
        self.assertIs(tracker, tracker.get('xxx', None))
 
251
        self.assertIs(None, tracker.get('yyy', None))
 
252
 
 
253
    def test_check_bug_id_only_accepts_project_integers(self):
 
254
        """Accepts integers as bug IDs."""
 
255
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
 
256
                'http://bugs.example.com/{project}/{id}')
 
257
        tracker.check_bug_id('project/1234')
 
258
 
 
259
    def test_check_bug_id_doesnt_accept_non_project_integers(self):
 
260
        """Rejects non-integers as bug IDs."""
 
261
        tracker = bugtracker.ProjectIntegerBugTracker('xxx',
 
262
                'http://bugs.example.com/{project}/{id}')
 
263
        self.assertRaises(
 
264
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, 'red')
 
265
        self.assertRaises(
 
266
            bugtracker.MalformedBugIdentifier, tracker.check_bug_id, '1234')
 
267
 
211
268
 
212
269
class TestURLParametrizedBugTracker(TestCaseWithMemoryTransport):
213
270
    """Tests for URLParametrizedBugTracker."""