~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

remove all trailing whitespace from bzr source

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
These are proxy objects which act on remote objects by sending messages
20
20
through a smart client.  The proxies are to be created when attempting to open
21
 
the object given a transport that supports smartserver rpc operations. 
 
21
the object given a transport that supports smartserver rpc operations.
22
22
 
23
23
These tests correspond to tests.test_smart, which exercises the server side.
24
24
"""
115
115
 
116
116
class FakeRemoteTransport(object):
117
117
    """This class provides the minimum support for use in place of a RemoteTransport.
118
 
    
 
118
 
119
119
    It doesn't actually transmit requests, but rather expects them to be
120
120
    handled by a FakeClient which holds canned responses.  It does not allow
121
121
    any vfs access, therefore is not suitable for testing any operation that
170
170
 
171
171
class FakeClient(_SmartClient):
172
172
    """Lookalike for _SmartClient allowing testing."""
173
 
    
 
173
 
174
174
    def __init__(self, fake_medium_base='fake base'):
175
175
        """Create a FakeClient."""
176
176
        self.responses = []
310
310
        cloned_transport = base_transport.clone(relpath)
311
311
        result = client_medium.remote_path_from_transport(cloned_transport)
312
312
        self.assertEqual(expected, result)
313
 
        
 
313
 
314
314
    def test_remote_path_from_transport_http(self):
315
315
        """Remote paths for HTTP transports are calculated differently to other
316
316
        transports.  They are just relative to the client base, not the root
332
332
        """
333
333
        client_medium = medium.SmartClientMedium('dummy base')
334
334
        self.assertFalse(client_medium._is_remote_before((99, 99)))
335
 
    
 
335
 
336
336
    def test__remember_remote_is_before(self):
337
337
        """Calling _remember_remote_is_before ratchets down the known remote
338
338
        version.
509
509
 
510
510
    def make_remote_branch(self, transport, client):
511
511
        """Make a RemoteBranch using 'client' as its _SmartClient.
512
 
        
 
512
 
513
513
        A RemoteBzrDir and RemoteRepository will also be created to fill out
514
514
        the RemoteBranch, albeit with stub values for some of their attributes.
515
515
        """
998
998
 
999
999
    def test_error_from_old_server(self):
1000
1000
        """bzr 0.15 and earlier servers don't recognise the is_readonly verb.
1001
 
        
 
1001
 
1002
1002
        Clients should treat it as a "no" response, because is_readonly is only
1003
1003
        advisory anyway (a transport could be read-write, but then the
1004
1004
        underlying filesystem could be readonly anyway).
1044
1044
 
1045
1045
class TestRemoteRepository(tests.TestCase):
1046
1046
    """Base for testing RemoteRepository protocol usage.
1047
 
    
1048
 
    These tests contain frozen requests and responses.  We want any changes to 
 
1047
 
 
1048
    These tests contain frozen requests and responses.  We want any changes to
1049
1049
    what is sent or expected to be require a thoughtful update to these tests
1050
1050
    because they might break compatibility with different-versioned servers.
1051
1051
    """
1052
1052
 
1053
1053
    def setup_fake_client_and_repository(self, transport_path):
1054
1054
        """Create the fake client and repository for testing with.
1055
 
        
 
1055
 
1056
1056
        There's no real server here; we just have canned responses sent
1057
1057
        back one by one.
1058
 
        
 
1058
 
1059
1059
        :param transport_path: Path below the root of the MemoryTransport
1060
1060
            where the repository will be created.
1061
1061
        """
1257
1257
 
1258
1258
 
1259
1259
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
1260
 
    
 
1260
 
1261
1261
    def test_null_revision(self):
1262
1262
        # a null revision has the predictable result {}, we should have no wire
1263
1263
        # traffic when calling it with this argument
1327
1327
            self.applyDeprecated, one_four, repo.get_revision_graph, revid)
1328
1328
        self.assertEqual(('AnUnexpectedError',), e.error_tuple)
1329
1329
 
1330
 
        
 
1330
 
1331
1331
class TestRepositoryIsShared(TestRemoteRepository):
1332
1332
 
1333
1333
    def test_is_shared(self):
1493
1493
    def reload_pack_names(self):
1494
1494
        self.calls.append(('pack collection reload_pack_names',))
1495
1495
 
1496
 
    
 
1496
 
1497
1497
class TestRemotePackRepositoryAutoPack(TestRemoteRepository):
1498
1498
    """Tests for RemoteRepository.autopack implementation."""
1499
1499
 
1523
1523
            [('call', 'PackRepository.autopack', ('quack/',)),
1524
1524
             ('pack collection reload_pack_names',)],
1525
1525
            client._calls)
1526
 
        
 
1526
 
1527
1527
    def test_backwards_compatibility(self):
1528
1528
        """If the server does not recognise the PackRepository.autopack verb,
1529
1529
        fallback to the real_repository's implementation.
1579
1579
 
1580
1580
class TestErrorTranslationSuccess(TestErrorTranslationBase):
1581
1581
    """Unit tests for bzrlib.remote._translate_error.
1582
 
    
 
1582
 
1583
1583
    Given an ErrorFromSmartServer (which has an error tuple from a smart
1584
1584
    server) and some context, _translate_error raises more specific errors from
1585
1585
    bzrlib.errors.
1690
1690
 
1691
1691
class TestErrorTranslationRobustness(TestErrorTranslationBase):
1692
1692
    """Unit tests for bzrlib.remote._translate_error's robustness.
1693
 
    
 
1693
 
1694
1694
    TestErrorTranslationSuccess is for cases where _translate_error can
1695
1695
    translate successfully.  This class about how _translate_err behaves when
1696
1696
    it fails to translate: it re-raises the original error.
1724
1724
        self.assertContainsRe(
1725
1725
            self._get_log(keep_log_file=True),
1726
1726
            "Missing key 'branch' in context")
1727
 
        
 
1727
 
1728
1728
    def test_path_missing(self):
1729
1729
        """Some translations (PermissionDenied, ReadError) can determine the
1730
1730
        'path' variable from either the wire or the local context.  If neither
1742
1742
 
1743
1743
class TestStacking(tests.TestCaseWithTransport):
1744
1744
    """Tests for operations on stacked remote repositories.
1745
 
    
 
1745
 
1746
1746
    The underlying format type must support stacking.
1747
1747
    """
1748
1748