~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 05:30:30 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115053030-1d6qd89pnj8hmb55
Pass kinds (not pairs) to MergeHookParams.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
import os
19
19
import warnings
20
20
 
21
21
from bzrlib import (
 
22
    bugtracker,
22
23
    revision,
23
24
    symbol_versioning,
24
25
    )
25
26
from bzrlib.branch import Branch
26
 
from bzrlib.errors import NoSuchRevision
 
27
from bzrlib.errors import (
 
28
    InvalidBugStatus,
 
29
    InvalidLineInBugsProperty,
 
30
    NoSuchRevision,
 
31
    )
27
32
from bzrlib.deprecated_graph import Graph
28
33
from bzrlib.revision import (find_present_ancestors,
29
34
                             NULL_REVISION)
30
 
from bzrlib.symbol_versioning import one_three
31
35
from bzrlib.tests import TestCase, TestCaseWithTransport
32
36
from bzrlib.trace import mutter
33
37
from bzrlib.workingtree import WorkingTree
123
127
                       rev_id, branch.repository.get_ancestry(rev_id))
124
128
                result = sorted(branch.repository.get_ancestry(rev_id))
125
129
                self.assertEquals(result, [None] + sorted(anc))
126
 
    
 
130
 
127
131
 
128
132
class TestIntermediateRevisions(TestCaseWithTransport):
129
133
 
204
208
        self.assertEqual('a', r.get_summary())
205
209
        r.message = '\na\nb'
206
210
        self.assertEqual('a', r.get_summary())
 
211
        r.message = None
 
212
        self.assertEqual('', r.get_summary())
207
213
 
208
214
    def test_get_apparent_author(self):
209
215
        r = revision.Revision('1')
210
216
        r.committer = 'A'
211
 
        self.assertEqual('A', r.get_apparent_author())
212
 
        r.properties['author'] = 'B'
213
 
        self.assertEqual('B', r.get_apparent_author())
 
217
        author = self.applyDeprecated(
 
218
                symbol_versioning.deprecated_in((1, 13, 0)),
 
219
                r.get_apparent_author)
 
220
        self.assertEqual('A', author)
 
221
        r.properties['author'] = 'B'
 
222
        author = self.applyDeprecated(
 
223
                symbol_versioning.deprecated_in((1, 13, 0)),
 
224
                r.get_apparent_author)
 
225
        self.assertEqual('B', author)
 
226
        r.properties['authors'] = 'C\nD'
 
227
        author = self.applyDeprecated(
 
228
                symbol_versioning.deprecated_in((1, 13, 0)),
 
229
                r.get_apparent_author)
 
230
        self.assertEqual('C', author)
 
231
 
 
232
    def test_get_apparent_author_none(self):
 
233
        r = revision.Revision('1')
 
234
        author = self.applyDeprecated(
 
235
                symbol_versioning.deprecated_in((1, 13, 0)),
 
236
                r.get_apparent_author)
 
237
        self.assertEqual(None, author)
 
238
 
 
239
    def test_get_apparent_authors(self):
 
240
        r = revision.Revision('1')
 
241
        r.committer = 'A'
 
242
        self.assertEqual(['A'], r.get_apparent_authors())
 
243
        r.properties['author'] = 'B'
 
244
        self.assertEqual(['B'], r.get_apparent_authors())
 
245
        r.properties['authors'] = 'C\nD'
 
246
        self.assertEqual(['C', 'D'], r.get_apparent_authors())
 
247
 
 
248
    def test_get_apparent_authors_no_committer(self):
 
249
        r = revision.Revision('1')
 
250
        self.assertEqual([], r.get_apparent_authors())
 
251
 
 
252
 
 
253
class TestRevisionBugs(TestCase):
 
254
    """Tests for getting the bugs that a revision is linked to."""
 
255
 
 
256
    def test_no_bugs(self):
 
257
        r = revision.Revision('1')
 
258
        self.assertEqual([], list(r.iter_bugs()))
 
259
 
 
260
    def test_some_bugs(self):
 
261
        r = revision.Revision(
 
262
            '1', properties={
 
263
                'bugs': bugtracker.encode_fixes_bug_urls(
 
264
                    ['http://example.com/bugs/1',
 
265
                     'http://launchpad.net/bugs/1234'])})
 
266
        self.assertEqual(
 
267
            [('http://example.com/bugs/1', bugtracker.FIXED),
 
268
             ('http://launchpad.net/bugs/1234', bugtracker.FIXED)],
 
269
            list(r.iter_bugs()))
 
270
 
 
271
    def test_no_status(self):
 
272
        r = revision.Revision(
 
273
            '1', properties={'bugs': 'http://example.com/bugs/1'})
 
274
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
 
275
 
 
276
    def test_too_much_information(self):
 
277
        r = revision.Revision(
 
278
            '1', properties={'bugs': 'http://example.com/bugs/1 fixed bar'})
 
279
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
 
280
 
 
281
    def test_invalid_status(self):
 
282
        r = revision.Revision(
 
283
            '1', properties={'bugs': 'http://example.com/bugs/1 faxed'})
 
284
        self.assertRaises(InvalidBugStatus, list, r.iter_bugs())