~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

(jelmer) Add HPSS call for ``Repository.iter_files_bytes``. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1541
1541
        tree.branch.repository.start_write_group()
1542
1542
        write_group_tokens = tree.branch.repository.suspend_write_group()
1543
1543
        self.assertEqual(None, request.execute('', write_token,
1544
 
            write_group_tokens, 'rev1'))
 
1544
            'rev1', *write_group_tokens))
1545
1545
        response = request.do_body('somesignature')
1546
1546
        self.assertTrue(response.is_successful())
1547
1547
        self.assertEqual(response.args[0], 'ok')
1849
1849
            request.execute('', rev_id_utf8))
1850
1850
 
1851
1851
 
 
1852
class TestSmartServerRepositoryIterFilesBytes(tests.TestCaseWithTransport):
 
1853
 
 
1854
    def test_single(self):
 
1855
        backing = self.get_transport()
 
1856
        request = smart_repo.SmartServerRepositoryIterFilesBytes(backing)
 
1857
        t = self.make_branch_and_tree('.')
 
1858
        self.addCleanup(t.lock_write().unlock)
 
1859
        self.build_tree_contents([("file", "somecontents")])
 
1860
        t.add(["file"], ["thefileid"])
 
1861
        t.commit(rev_id='somerev', message="add file")
 
1862
        self.assertIs(None, request.execute(''))
 
1863
        response = request.do_body("thefileid\0somerev\n")
 
1864
        self.assertTrue(response.is_successful())
 
1865
        self.assertEquals(response.args, ("ok", ))
 
1866
        self.assertEquals("".join(response.body_stream),
 
1867
            "ok\x000\n" + zlib.compress("somecontents"))
 
1868
 
 
1869
    def test_missing(self):
 
1870
        backing = self.get_transport()
 
1871
        request = smart_repo.SmartServerRepositoryIterFilesBytes(backing)
 
1872
        t = self.make_branch_and_tree('.')
 
1873
        self.addCleanup(t.lock_write().unlock)
 
1874
        self.assertIs(None, request.execute(''))
 
1875
        response = request.do_body("thefileid\0revision\n")
 
1876
        self.assertTrue(response.is_successful())
 
1877
        self.assertEquals(response.args, ("ok", ))
 
1878
        self.assertEquals("".join(response.body_stream),
 
1879
            "absent\x00thefileid\x00revision\x000\n")
 
1880
 
 
1881
 
1852
1882
class TestSmartServerRequestHasSignatureForRevisionId(
1853
1883
        tests.TestCaseWithMemoryTransport):
1854
1884
 
2472
2502
            smart_repo.SmartServerRepositoryInsertStreamLocked)
2473
2503
        self.assertHandlerEqual('Repository.is_shared',
2474
2504
            smart_repo.SmartServerRepositoryIsShared)
 
2505
        self.assertHandlerEqual('Repository.iter_files_bytes',
 
2506
            smart_repo.SmartServerRepositoryIterFilesBytes)
2475
2507
        self.assertHandlerEqual('Repository.lock_write',
2476
2508
            smart_repo.SmartServerRepositoryLockWrite)
2477
2509
        self.assertHandlerEqual('Repository.make_working_trees',