~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Andrew Bennetts
  • Date: 2009-03-16 05:47:53 UTC
  • mto: This revision was merged to the branch mainline in revision 4148.
  • Revision ID: andrew.bennetts@canonical.com-20090316054753-0mfo07r21tsjl5p0
Use Repository.insert_stream_locked if there is a lock_token for the remote repo.

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
        return result[1], None
274
275
 
275
276
 
276
277
class FakeMedium(medium.SmartClientMedium):
1825
1826
        self.assertEqual([], client._calls)
1826
1827
 
1827
1828
 
 
1829
class TestRepositoryInsertStream(TestRemoteRepository):
 
1830
 
 
1831
    def test_unlocked_repo(self):
 
1832
        transport_path = 'quack'
 
1833
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1834
        client.add_expected_call(
 
1835
            'Repository.insert_stream', ('quack/', ''),
 
1836
            'success', ('ok',))
 
1837
        client.add_expected_call(
 
1838
            'Repository.insert_stream', ('quack/', ''),
 
1839
            'success', ('ok',))
 
1840
        sink = repo._get_sink()
 
1841
        fmt = repository.RepositoryFormat.get_default_format()
 
1842
        resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
 
1843
        self.assertEqual([], resume_tokens)
 
1844
        self.assertEqual(set(), missing_keys)
 
1845
        client.finished_test()
 
1846
 
 
1847
    def test_locked_repo_with_no_lock_token(self):
 
1848
        transport_path = 'quack'
 
1849
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1850
        client.add_expected_call(
 
1851
            'Repository.lock_write', ('quack/', ''),
 
1852
            'success', ('ok', ''))
 
1853
        client.add_expected_call(
 
1854
            'Repository.insert_stream', ('quack/', ''),
 
1855
            'success', ('ok',))
 
1856
        client.add_expected_call(
 
1857
            'Repository.insert_stream', ('quack/', ''),
 
1858
            'success', ('ok',))
 
1859
        repo.lock_write()
 
1860
        sink = repo._get_sink()
 
1861
        fmt = repository.RepositoryFormat.get_default_format()
 
1862
        resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
 
1863
        self.assertEqual([], resume_tokens)
 
1864
        self.assertEqual(set(), missing_keys)
 
1865
        client.finished_test()
 
1866
 
 
1867
    def test_locked_repo_with_lock_token(self):
 
1868
        transport_path = 'quack'
 
1869
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1870
        client.add_expected_call(
 
1871
            'Repository.lock_write', ('quack/', ''),
 
1872
            'success', ('ok', 'a token'))
 
1873
        client.add_expected_call(
 
1874
            'Repository.insert_stream_locked', ('quack/', '', 'a token'),
 
1875
            'success', ('ok',))
 
1876
        client.add_expected_call(
 
1877
            'Repository.insert_stream_locked', ('quack/', '', 'a token'),
 
1878
            'success', ('ok',))
 
1879
        repo.lock_write()
 
1880
        sink = repo._get_sink()
 
1881
        fmt = repository.RepositoryFormat.get_default_format()
 
1882
        resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
 
1883
        self.assertEqual([], resume_tokens)
 
1884
        self.assertEqual(set(), missing_keys)
 
1885
        client.finished_test()
 
1886
 
 
1887
 
1828
1888
class TestRepositoryTarball(TestRemoteRepository):
1829
1889
 
1830
1890
    # This is a canned tarball reponse we can validate against