~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bugtracker.py

  • Committer: John Arbash Meinel
  • Date: 2008-09-26 22:14:42 UTC
  • mto: This revision was merged to the branch mainline in revision 3747.
  • Revision ID: john@arbash-meinel.com-20080926221442-3r67j99sr9rwe9w0
Make message optional, don't check the memory flag directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
        self.assertEqual('http://bugs.debian.org/1234',
82
82
                         tracker.get_bug_url('1234'))
83
83
 
 
84
    def test_gnome_registered(self):
 
85
        branch = self.make_branch('some_branch')
 
86
        tracker = bugtracker.tracker_registry.get_tracker('gnome', branch)
 
87
        self.assertEqual('http://bugzilla.gnome.org/show_bug.cgi?id=1234',
 
88
                         tracker.get_bug_url('1234'))
 
89
 
84
90
    def test_trac_registered(self):
85
91
        """The Trac bug tracker should be registered by default and generate
86
92
        Trac bug page URLs when the appropriate configuration is present.
104
110
        self.assertEqual('http://bugs.com/show_bug.cgi?id=1234',
105
111
                         tracker.get_bug_url('1234'))
106
112
 
 
113
    def test_generic_registered(self):
 
114
        branch = self.make_branch('some_branch')
 
115
        config = branch.get_config()
 
116
        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/{id}/view.html')
 
117
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
 
118
        self.assertEqual('http://bugs.com/1234/view.html',
 
119
                         tracker.get_bug_url('1234'))
 
120
 
 
121
    def test_generic_incorrect_url(self):
 
122
        branch = self.make_branch('some_branch')
 
123
        config = branch.get_config()
 
124
        config.set_user_option('bugtracker_foo_url', 'http://bugs.com/view.html')
 
125
        tracker = bugtracker.tracker_registry.get_tracker('foo', branch)
 
126
        self.assertRaises(errors.InvalidBugTrackerURL, tracker.get_bug_url, '1234')
 
127
 
107
128
 
108
129
class TestUniqueIntegerBugTracker(TestCaseWithMemoryTransport):
109
130
 
110
 
    def test_joins_id_to_base_url(self):
 
131
    def test_appends_id_to_base_url(self):
111
132
        """The URL of a bug is the base URL joined to the identifier."""
112
 
        tracker = bugtracker.UniqueIntegerBugTracker('xxx', 'http://bugs.com')
113
 
        self.assertEqual('http://bugs.com/1234', tracker.get_bug_url('1234'))
 
133
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
 
134
                'http://bugs.com/foo')
 
135
        self.assertEqual('http://bugs.com/foo1234', tracker.get_bug_url('1234'))
114
136
 
115
137
    def test_returns_tracker_if_abbreviation_matches(self):
116
138
        """The get() method should return an instance of the tracker if the
117
139
        given abbreviation matches the tracker's abbreviated name.
118
140
        """
119
 
        tracker = bugtracker.UniqueIntegerBugTracker('xxx', 'http://bugs.com')
 
141
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
 
142
                'http://bugs.com/')
120
143
        branch = self.make_branch('some_branch')
121
144
        self.assertIs(tracker, tracker.get('xxx', branch))
122
145
 
124
147
        """The get() method should return None if the given abbreviated name
125
148
        doesn't match the tracker's abbreviation.
126
149
        """
127
 
        tracker = bugtracker.UniqueIntegerBugTracker('xxx', 'http://bugs.com')
 
150
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
 
151
                'http://bugs.com/')
128
152
        branch = self.make_branch('some_branch')
129
153
        self.assertIs(None, tracker.get('yyy', branch))
130
154
 
132
156
        """A UniqueIntegerBugTracker shouldn't consult the branch for tracker
133
157
        information.
134
158
        """
135
 
        tracker = bugtracker.UniqueIntegerBugTracker('xxx', 'http://bugs.com')
 
159
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
 
160
                'http://bugs.com/')
136
161
        self.assertIs(tracker, tracker.get('xxx', None))
137
162
        self.assertIs(None, tracker.get('yyy', None))
138
163
 
139
164
    def test_check_bug_id_only_accepts_integers(self):
140
165
        """A UniqueIntegerBugTracker accepts integers as bug IDs."""
141
 
        tracker = bugtracker.UniqueIntegerBugTracker('xxx', 'http://bugs.com')
 
166
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
 
167
                'http://bugs.com/')
142
168
        tracker.check_bug_id('1234')
143
169
 
144
170
    def test_check_bug_id_doesnt_accept_non_integers(self):
145
171
        """A UniqueIntegerBugTracker rejects non-integers as bug IDs."""
146
 
        tracker = bugtracker.UniqueIntegerBugTracker('xxx', 'http://bugs.com')
 
172
        tracker = bugtracker.UniqueIntegerBugTracker('xxx',
 
173
                'http://bugs.com/')
147
174
        self.assertRaises(
148
175
            errors.MalformedBugIdentifier, tracker.check_bug_id, 'red')
149
176