~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-16 06:51:36 UTC
  • mfrom: (4144.3.5 simplify-interrepo-stack)
  • Revision ID: pqm@pqm.ubuntu.com-20090316065136-1g3udxbvvlgtsbup
(andrew) Add RPC that can insert a stream into older (i.e. lockable)
        repository formats.

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
        stream = list(stream)
271
271
        self._check_call(args[0], args[1:])
272
272
        self._calls.append(('call_with_body_stream', args[0], args[1:], stream))
273
 
        return self._get_next_response()[1]
 
273
        result = self._get_next_response()
 
274
        # The second value returned from call_with_body_stream is supposed to
 
275
        # be a response_handler object, but so far no tests depend on that.
 
276
        response_handler = None 
 
277
        return result[1], response_handler
274
278
 
275
279
 
276
280
class FakeMedium(medium.SmartClientMedium):
1825
1829
        self.assertEqual([], client._calls)
1826
1830
 
1827
1831
 
 
1832
class TestRepositoryInsertStream(TestRemoteRepository):
 
1833
 
 
1834
    def test_unlocked_repo(self):
 
1835
        transport_path = 'quack'
 
1836
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1837
        client.add_expected_call(
 
1838
            'Repository.insert_stream', ('quack/', ''),
 
1839
            'success', ('ok',))
 
1840
        client.add_expected_call(
 
1841
            'Repository.insert_stream', ('quack/', ''),
 
1842
            'success', ('ok',))
 
1843
        sink = repo._get_sink()
 
1844
        fmt = repository.RepositoryFormat.get_default_format()
 
1845
        resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
 
1846
        self.assertEqual([], resume_tokens)
 
1847
        self.assertEqual(set(), missing_keys)
 
1848
        client.finished_test()
 
1849
 
 
1850
    def test_locked_repo_with_no_lock_token(self):
 
1851
        transport_path = 'quack'
 
1852
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1853
        client.add_expected_call(
 
1854
            'Repository.lock_write', ('quack/', ''),
 
1855
            'success', ('ok', ''))
 
1856
        client.add_expected_call(
 
1857
            'Repository.insert_stream', ('quack/', ''),
 
1858
            'success', ('ok',))
 
1859
        client.add_expected_call(
 
1860
            'Repository.insert_stream', ('quack/', ''),
 
1861
            'success', ('ok',))
 
1862
        repo.lock_write()
 
1863
        sink = repo._get_sink()
 
1864
        fmt = repository.RepositoryFormat.get_default_format()
 
1865
        resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
 
1866
        self.assertEqual([], resume_tokens)
 
1867
        self.assertEqual(set(), missing_keys)
 
1868
        client.finished_test()
 
1869
 
 
1870
    def test_locked_repo_with_lock_token(self):
 
1871
        transport_path = 'quack'
 
1872
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1873
        client.add_expected_call(
 
1874
            'Repository.lock_write', ('quack/', ''),
 
1875
            'success', ('ok', 'a token'))
 
1876
        client.add_expected_call(
 
1877
            'Repository.insert_stream_locked', ('quack/', '', 'a token'),
 
1878
            'success', ('ok',))
 
1879
        client.add_expected_call(
 
1880
            'Repository.insert_stream_locked', ('quack/', '', 'a token'),
 
1881
            'success', ('ok',))
 
1882
        repo.lock_write()
 
1883
        sink = repo._get_sink()
 
1884
        fmt = repository.RepositoryFormat.get_default_format()
 
1885
        resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
 
1886
        self.assertEqual([], resume_tokens)
 
1887
        self.assertEqual(set(), missing_keys)
 
1888
        client.finished_test()
 
1889
 
 
1890
 
1828
1891
class TestRepositoryTarball(TestRemoteRepository):
1829
1892
 
1830
1893
    # This is a canned tarball reponse we can validate against