~bzr-pqm/bzr/bzr.dev

1185.16.35 by Martin Pool
- stub for revision properties
1
# (C) 2005 Canonical
2
3
"""Tests for revision properties."""
4
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
5
from bzrlib.tests import TestCaseWithTransport
6
7
class TestRevProps(TestCaseWithTransport):
8
1185.16.35 by Martin Pool
- stub for revision properties
9
    def test_simple_revprops(self):
10
        """Simple revision properties"""
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
11
        wt = self.make_branch_and_tree('.')
12
        b = wt.branch
1185.35.16 by Aaron Bentley
Fixed tests
13
        b.nick = 'Nicholas'
1185.16.35 by Martin Pool
- stub for revision properties
14
        props = dict(flavor='choc-mint', 
1185.16.39 by Martin Pool
- constraints on revprops
15
                     condiment='orange\n  mint\n\tcandy')
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
16
        wt.commit(message='initial null commit', 
1185.16.35 by Martin Pool
- stub for revision properties
17
                 revprops=props,
18
                 allow_pointless=True,
19
                 rev_id='test@user-1')
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
20
        rev = b.repository.get_revision('test@user-1')
1185.16.37 by Martin Pool
- properties are retrieved when revisions are loaded
21
        self.assertTrue('flavor' in rev.properties)
22
        self.assertEquals(rev.properties['flavor'], 'choc-mint')
23
        self.assertEquals(sorted(rev.properties.items()),
1185.35.16 by Aaron Bentley
Fixed tests
24
                          [('branch-nick', 'Nicholas'), 
25
                           ('condiment', 'orange\n  mint\n\tcandy'),
1185.16.37 by Martin Pool
- properties are retrieved when revisions are loaded
26
                           ('flavor', 'choc-mint')])
27
1185.16.39 by Martin Pool
- constraints on revprops
28
    def test_invalid_revprops(self):
29
        """Invalid revision properties"""
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
30
        wt = self.make_branch_and_tree('.')
31
        b = wt.branch
1185.16.39 by Martin Pool
- constraints on revprops
32
        self.assertRaises(ValueError,
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
33
                          wt.commit, 
1185.16.39 by Martin Pool
- constraints on revprops
34
                          message='invalid',
35
                          revprops={'what a silly property': 'fine'})
36
        self.assertRaises(ValueError,
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
37
                          wt.commit, 
1185.16.39 by Martin Pool
- constraints on revprops
38
                          message='invalid',
39
                          revprops=dict(number=13))