/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

Implement RemoteBranch.revision_history().

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the smart wire/domain protococl."""
18
18
 
19
 
from bzrlib import smart, tests
 
19
from bzrlib import errors, smart, tests
20
20
from bzrlib.smart.request import SmartServerResponse
21
21
import bzrlib.smart.bzrdir
 
22
import bzrlib.smart.branch
22
23
 
23
24
 
24
25
class TestSmartServerResponse(tests.TestCase):
103
104
        self.assertEqual(SmartServerResponse(('ok', reference_url)),
104
105
            request.execute(backing.local_abspath('reference')))
105
106
 
 
107
 
 
108
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithTransport):
 
109
 
 
110
    def test_no_branch(self):
 
111
        """When there is a bzrdir and no branch, NotBranchError is raised."""
 
112
        backing = self.get_transport()
 
113
        request = smart.branch.SmartServerRequestRevisionHistory(backing)
 
114
        self.make_bzrdir('.')
 
115
        self.assertRaises(errors.NotBranchError,
 
116
            request.execute, backing.local_abspath(''))
 
117
 
 
118
    def test_empty(self):
 
119
        """For an empty branch, the body is empty."""
 
120
        backing = self.get_transport()
 
121
        request = smart.branch.SmartServerRequestRevisionHistory(backing)
 
122
        self.make_branch('.')
 
123
        self.assertEqual(SmartServerResponse(('ok', ), ''),
 
124
            request.execute(backing.local_abspath('')))
 
125
 
 
126
    def test_not_empty(self):
 
127
        """For a non-empty branch, the body is empty."""
 
128
        backing = self.get_transport()
 
129
        request = smart.branch.SmartServerRequestRevisionHistory(backing)
 
130
        tree = self.make_branch_and_memory_tree('.')
 
131
        tree.lock_write()
 
132
        tree.add('')
 
133
        r1 = tree.commit('1st commit')
 
134
        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
 
135
        tree.unlock()
 
136
        self.assertEqual(SmartServerResponse(('ok', ),
 
137
            ('\x00'.join([r1, r2])).encode('utf8')),
 
138
            request.execute(backing.local_abspath('')))
 
139
 
 
140
    def test_branch_reference(self):
 
141
        """When there is a branch reference, NotBranchError is raised."""
 
142
        backing = self.get_transport()
 
143
        request = smart.branch.SmartServerRequestRevisionHistory(backing)
 
144
        branch = self.make_branch('branch')
 
145
        checkout = branch.create_checkout('reference',lightweight=True)
 
146
        self.assertRaises(errors.NotBranchError,
 
147
            request.execute, backing.local_abspath('checkout'))
 
148
 
 
149
 
106
150
class TestHandlers(tests.TestCase):
107
151
    """Tests for the request.request_handlers object."""
108
152
 
109
153
    def test_registered_methods(self):
110
154
        """Test that known methods are registered to the correct object."""
111
155
        self.assertEqual(
 
156
            smart.request.request_handlers.get('Branch.revision_history'),
 
157
            smart.branch.SmartServerRequestRevisionHistory)
 
158
        self.assertEqual(
112
159
            smart.request.request_handlers.get('BzrDir.find_repository'),
113
160
            smart.bzrdir.SmartServerRequestFindRepository)
114
161
        self.assertEqual(