1
# Copyright (C) 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib import bugtracker
19
from bzrlib.tests import TestCaseWithMemoryTransport
22
# XXX - the bare minimum of text to help me think.
24
Bug fix info is stored in revision properties: {bug_url: status}
26
But no one wants to type out bug URLs in full.
28
We want to map from <tag>:<bug_id> to <url>, where <tracker> refers to a
29
particular instance of a tracker.
31
For instance, twisted:123 -> http://twistedmatrix.com/trac/ticket/123
33
Of course, the mapping will be pretty much the same for all instances of any
34
given tracker software, so what we want to do is this:
36
- From <tag>, get a tracker type (like 'Trac', 'Bugzilla' or 'Launchpad')
37
- Give <tag> and <branch> to the tracker type
38
- The tracker type takes <tag> and <branch> and creates an instance of a
39
tracker that knows how to take <bug_id> and turn it into a URL.
43
class TestLaunchpadTracker(TestCaseWithMemoryTransport):
45
TestCaseWithMemoryTransport.setUp(self)
46
self.branch = self.make_branch('some_branch')
48
def test_get_with_unsupported_tag(self):
50
None, bugtracker.LaunchpadTracker.get('twisted', self.branch))
52
def test_get_with_supported_tag(self):
53
tracker = bugtracker.LaunchpadTracker.get('lp', self.branch)
54
self.assertEqual(bugtracker.LaunchpadTracker().get_bug_url('1234'),
55
tracker.get_bug_url('1234'))
57
def test_get_url(self):
59
'https://launchpad.net/bugs/1234',
60
bugtracker.get_url('lp', self.branch, '1234'))
62
def test_get_bug_url(self):
63
tracker = bugtracker.LaunchpadTracker()
64
self.assertEqual('https://launchpad.net/bugs/1234',
65
tracker.get_bug_url('1234'))
68
class TestTracTracker(TestCaseWithMemoryTransport):
70
TestCaseWithMemoryTransport.setUp(self)
71
self.trac_url = 'http://twistedmatrix.com/trac'
73
def test_get_url(self):
74
branch = self.make_branch('some_branch')
75
config = branch.get_config()
76
config.set_user_option('trac_twisted_url', self.trac_url)
77
self.assertEqual('%s/ticket/1234' % self.trac_url,
78
bugtracker.get_url('twisted', branch, '1234'))
80
def test_get_bug_url(self):
81
tracker = bugtracker.TracTracker(self.trac_url)
83
'%s/ticket/1234' % self.trac_url, tracker.get_bug_url('1234'))
85
def test_get_with_unsupported_tag(self):
86
branch = self.make_branch('some_branch')
87
self.assertEqual(None, bugtracker.TracTracker.get('lp', branch))
88
self.assertEqual(None, bugtracker.TracTracker.get('twisted', branch))
90
def test_get_with_supported_tag(self):
91
branch = self.make_branch('some_branch')
92
config = branch.get_config()
93
config.set_user_option('trac_twisted_url', self.trac_url)
94
tracker = bugtracker.TracTracker.get('twisted', branch)
96
bugtracker.TracTracker(self.trac_url).get_bug_url('1234'),
97
tracker.get_bug_url('1234'))