/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_remote.py

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
743
743
        finally:
744
744
            tarball_file.close()
745
745
 
 
746
    def test_sprout_uses_tarball(self):
 
747
        # XXX: update this for new streaming fetch method.
 
748
        raise tests.KnownFailure(
 
749
            'XXX: update this test for new streaming fetch method')
 
750
        # RemoteRepository.sprout should try to use the
 
751
        # tarball command rather than accessing all the files
 
752
        transport_path = 'srcrepo'
 
753
        expected_responses = [(('ok',), self.tarball_content),
 
754
            ]
 
755
        expected_calls = [('call2', 'Repository.tarball', ('///srcrepo/', 'bz2',),),
 
756
            ]
 
757
        remote_repo, client = self.setup_fake_client_and_repository(
 
758
            expected_responses, transport_path)
 
759
        # make a regular local repository to receive the results
 
760
        dest_transport = MemoryTransport()
 
761
        dest_transport.mkdir('destrepo')
 
762
        bzrdir_format = bzrdir.format_registry.make_bzrdir('default')
 
763
        dest_bzrdir = bzrdir_format.initialize_on_transport(dest_transport)
 
764
        # try to copy...
 
765
        remote_repo.sprout(dest_bzrdir)
 
766
 
 
767
    def test_backwards_compatibility(self):
 
768
        """If the server doesn't recognise this request, fallback to VFS.
 
769
        
 
770
        This happens when a current client talks to an older server that
 
771
        doesn't implement 'Repository.tarball'.
 
772
        """
 
773
        raise tests.KnownFailure("Mock isn't good enough?")
 
774
        # Make a regular local repository to receive the results
 
775
        dest_transport = MemoryTransport()
 
776
        dest_transport.mkdir('destrepo')
 
777
        bzrdir_format = bzrdir.format_registry.make_bzrdir('default')
 
778
        dest_bzrdir = bzrdir_format.initialize_on_transport(dest_transport)
 
779
 
 
780
        error_msg = (
 
781
            "Generic bzr smart protocol error: "
 
782
            "bad request 'Repository.tarball'")
 
783
        responses = [(('error', error_msg), '')]
 
784
        remote_repo, client = self.setup_fake_client_and_repository(
 
785
            responses, 'path')
 
786
        mock_real_repo = MockRealRepository()
 
787
        remote_repo._real_repository = mock_real_repo
 
788
 
 
789
        # try to copy...
 
790
        remote_repo.sprout(dest_bzrdir)
 
791
 
 
792
        self.assertEqual([('sprout', dest_bzrdir, None)], mock_real_repo.calls,
 
793
            "RemoteRepository didn't fallback to the real repository correctly")
 
794
        self.failIf(client.expecting_body,
 
795
            "The protocol has been left in an unclean state that will cause "
 
796
            "TooManyConcurrentRequests errors.")
 
797
 
 
798
 
 
799
class MockRealRepository(object):
 
800
    """Mock of a RemoteRepository's '_real_repository' attribute.
 
801
    
 
802
    Used by TestRepositoryTarball.test_backwards_compatibility.
 
803
    """
 
804
 
 
805
    def __init__(self):
 
806
        self.calls = []
 
807
 
 
808
    def sprout(self, to_bzrdir, revision_id=None):
 
809
        self.calls.append(('sprout', to_bzrdir, revision_id))
 
810
 
746
811
 
747
812
class TestRemoteRepositoryCopyContent(tests.TestCaseWithTransport):
748
813
    """RemoteRepository.copy_content_into optimizations"""