744
744
tarball_file.close()
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),
755
expected_calls = [('call2', 'Repository.tarball', ('///srcrepo/', 'bz2',),),
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)
765
remote_repo.sprout(dest_bzrdir)
767
def test_backwards_compatibility(self):
768
"""If the server doesn't recognise this request, fallback to VFS.
770
This happens when a current client talks to an older server that
771
doesn't implement 'Repository.tarball'.
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)
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(
786
mock_real_repo = MockRealRepository()
787
remote_repo._real_repository = mock_real_repo
790
remote_repo.sprout(dest_bzrdir)
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.")
799
class MockRealRepository(object):
800
"""Mock of a RemoteRepository's '_real_repository' attribute.
802
Used by TestRepositoryTarball.test_backwards_compatibility.
808
def sprout(self, to_bzrdir, revision_id=None):
809
self.calls.append(('sprout', to_bzrdir, revision_id))
747
812
class TestRemoteRepositoryCopyContent(tests.TestCaseWithTransport):
748
813
"""RemoteRepository.copy_content_into optimizations"""