~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

(jameinel) Allow 'bzr serve' to interpret SIGHUP as a graceful shutdown.
 (bug #795025) (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
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
16
 
 
17
 
 
18
 
import os
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
 
19
18
import warnings
20
19
 
21
20
from bzrlib import (
 
21
    bugtracker,
22
22
    revision,
23
 
    symbol_versioning,
24
 
    )
25
 
from bzrlib.branch import Branch
26
 
from bzrlib.errors import NoSuchRevision
27
 
from bzrlib.deprecated_graph import Graph
28
 
from bzrlib.revision import (find_present_ancestors,
29
 
                             NULL_REVISION)
30
 
from bzrlib.symbol_versioning import one_three
 
23
    )
 
24
from bzrlib.errors import (
 
25
    InvalidBugStatus,
 
26
    InvalidLineInBugsProperty,
 
27
    )
 
28
from bzrlib.revision import NULL_REVISION
31
29
from bzrlib.tests import TestCase, TestCaseWithTransport
32
 
from bzrlib.trace import mutter
33
 
from bzrlib.workingtree import WorkingTree
 
30
from bzrlib.tests.matchers import MatchesAncestry
34
31
 
35
32
# We're allowed to test deprecated interfaces
36
33
warnings.filterwarnings('ignore',
107
104
             ('a@u-0-5', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
108
105
                          'b@u-0-3', 'b@u-0-4',
109
106
                          'b@u-0-5', 'a@u-0-5']),
110
 
             ('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2',
 
107
             ('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-4',
111
108
                          'b@u-0-3', 'b@u-0-4',
112
109
                          'b@u-0-5', 'b@u-0-6']),
113
110
             ]
119
116
                    continue
120
117
                if rev_id in br2_only and not branch is br2:
121
118
                    continue
122
 
                mutter('ancestry of {%s}: %r',
123
 
                       rev_id, branch.repository.get_ancestry(rev_id))
124
 
                result = sorted(branch.repository.get_ancestry(rev_id))
125
 
                self.assertEquals(result, [None] + sorted(anc))
126
 
    
 
119
                self.assertThat(anc,
 
120
                    MatchesAncestry(branch.repository, rev_id))
 
121
 
127
122
 
128
123
class TestIntermediateRevisions(TestCaseWithTransport):
129
124
 
204
199
        self.assertEqual('a', r.get_summary())
205
200
        r.message = '\na\nb'
206
201
        self.assertEqual('a', r.get_summary())
 
202
        r.message = None
 
203
        self.assertEqual('', r.get_summary())
207
204
 
208
 
    def test_get_apparent_author(self):
 
205
    def test_get_apparent_authors(self):
209
206
        r = revision.Revision('1')
210
207
        r.committer = 'A'
211
 
        self.assertEqual('A', r.get_apparent_author())
 
208
        self.assertEqual(['A'], r.get_apparent_authors())
212
209
        r.properties['author'] = 'B'
213
 
        self.assertEqual('B', r.get_apparent_author())
 
210
        self.assertEqual(['B'], r.get_apparent_authors())
 
211
        r.properties['authors'] = 'C\nD'
 
212
        self.assertEqual(['C', 'D'], r.get_apparent_authors())
 
213
 
 
214
    def test_get_apparent_authors_no_committer(self):
 
215
        r = revision.Revision('1')
 
216
        self.assertEqual([], r.get_apparent_authors())
 
217
 
 
218
 
 
219
class TestRevisionBugs(TestCase):
 
220
    """Tests for getting the bugs that a revision is linked to."""
 
221
 
 
222
    def test_no_bugs(self):
 
223
        r = revision.Revision('1')
 
224
        self.assertEqual([], list(r.iter_bugs()))
 
225
 
 
226
    def test_some_bugs(self):
 
227
        r = revision.Revision(
 
228
            '1', properties={
 
229
                'bugs': bugtracker.encode_fixes_bug_urls(
 
230
                    ['http://example.com/bugs/1',
 
231
                     'http://launchpad.net/bugs/1234'])})
 
232
        self.assertEqual(
 
233
            [('http://example.com/bugs/1', bugtracker.FIXED),
 
234
             ('http://launchpad.net/bugs/1234', bugtracker.FIXED)],
 
235
            list(r.iter_bugs()))
 
236
 
 
237
    def test_no_status(self):
 
238
        r = revision.Revision(
 
239
            '1', properties={'bugs': 'http://example.com/bugs/1'})
 
240
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
 
241
 
 
242
    def test_too_much_information(self):
 
243
        r = revision.Revision(
 
244
            '1', properties={'bugs': 'http://example.com/bugs/1 fixed bar'})
 
245
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
 
246
 
 
247
    def test_invalid_status(self):
 
248
        r = revision.Revision(
 
249
            '1', properties={'bugs': 'http://example.com/bugs/1 faxed'})
 
250
        self.assertRaises(InvalidBugStatus, list, r.iter_bugs())