~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil).

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    RemoteBranch,
29
29
    RemoteBzrDir,
30
30
    RemoteBzrDirFormat,
 
31
    RemoteRepository,
31
32
    )
32
33
from bzrlib.revision import NULL_REVISION
33
34
from bzrlib.smart import server
129
130
            [('call', 'Branch.last_revision_info', ('///kwaak/',))],
130
131
            client._calls)
131
132
        self.assertEqual((2, u'\xc8'), result)
 
133
 
 
134
 
 
135
class TestRepositoryIsShared(tests.TestCase):
 
136
 
 
137
    def setup_fake_client_and_repository(self, responses, transport_path):
 
138
        """Create the fake client and repository for testing with."""
 
139
        client = FakeClient(responses)
 
140
        transport = MemoryTransport()
 
141
        transport.mkdir(transport_path)
 
142
        transport = transport.clone(transport_path)
 
143
        # we do not want bzrdir to make any remote calls
 
144
        bzrdir = RemoteBzrDir(transport, _client=False)
 
145
        repo = RemoteRepository(bzrdir, None, _client=client)
 
146
        return repo, client
 
147
 
 
148
    def test_is_shared(self):
 
149
        # ('yes', ) for Repository.is_shared -> 'True'.
 
150
        responses = [('yes', )]
 
151
        transport_path = 'quack'
 
152
        repo, client = self.setup_fake_client_and_repository(
 
153
            responses, transport_path)
 
154
        result = repo.is_shared()
 
155
        self.assertEqual(
 
156
            [('call', 'Repository.is_shared', ('///quack/',))],
 
157
            client._calls)
 
158
        self.assertEqual(True, result)
 
159
 
 
160
    def test_is_not_shared(self):
 
161
        # ('no', ) for Repository.is_shared -> 'False'.
 
162
        responses = [('no', )]
 
163
        transport_path = 'qwack'
 
164
        repo, client = self.setup_fake_client_and_repository(
 
165
            responses, transport_path)
 
166
        result = repo.is_shared()
 
167
        self.assertEqual(
 
168
            [('call', 'Repository.is_shared', ('///qwack/',))],
 
169
            client._calls)
 
170
        self.assertEqual(False, result)