~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Patch Queue Manager
  • Date: 2011-11-28 13:54:33 UTC
  • mfrom: (6280.9.12 hpss-get-revisions)
  • Revision ID: pqm@pqm.ubuntu.com-20111128135433-xoddhlxx9qgi4u5k
(jelmer) Add a ``Repository.iter_revisions`` HPSS call. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
"""
26
26
 
27
27
import bz2
 
28
import zlib
28
29
 
29
30
from bzrlib import (
30
31
    branch as _mod_branch,
1724
1725
            request.execute('stacked', 1, (3, r3)))
1725
1726
 
1726
1727
 
 
1728
class TestSmartServerRepositoryIterRevisions(
 
1729
    tests.TestCaseWithMemoryTransport):
 
1730
 
 
1731
    def test_basic(self):
 
1732
        backing = self.get_transport()
 
1733
        request = smart_repo.SmartServerRepositoryIterRevisions(backing)
 
1734
        tree = self.make_branch_and_memory_tree('.', format='2a')
 
1735
        tree.lock_write()
 
1736
        tree.add('')
 
1737
        tree.commit('1st commit', rev_id="rev1")
 
1738
        tree.commit('2nd commit', rev_id="rev2")
 
1739
        tree.unlock()
 
1740
 
 
1741
        self.assertIs(None, request.execute(''))
 
1742
        response = request.do_body("rev1\nrev2")
 
1743
        self.assertTrue(response.is_successful())
 
1744
        # Format 2a uses serializer format 10
 
1745
        self.assertEquals(response.args, ("ok", "10"))
 
1746
 
 
1747
        self.addCleanup(tree.branch.lock_read().unlock)
 
1748
        entries = [zlib.compress(record.get_bytes_as("fulltext")) for record in
 
1749
            tree.branch.repository.revisions.get_record_stream(
 
1750
            [("rev1", ), ("rev2", )], "unordered", True)]
 
1751
 
 
1752
        contents = "".join(response.body_stream)
 
1753
        self.assertTrue(contents in (
 
1754
            "".join([entries[0], entries[1]]),
 
1755
            "".join([entries[1], entries[0]])))
 
1756
 
 
1757
    def test_missing(self):
 
1758
        backing = self.get_transport()
 
1759
        request = smart_repo.SmartServerRepositoryIterRevisions(backing)
 
1760
        tree = self.make_branch_and_memory_tree('.', format='2a')
 
1761
 
 
1762
        self.assertIs(None, request.execute(''))
 
1763
        response = request.do_body("rev1\nrev2")
 
1764
        self.assertTrue(response.is_successful())
 
1765
        # Format 2a uses serializer format 10
 
1766
        self.assertEquals(response.args, ("ok", "10"))
 
1767
 
 
1768
        contents = "".join(response.body_stream)
 
1769
        self.assertEquals(contents, "")
 
1770
 
 
1771
 
1727
1772
class GetStreamTestBase(tests.TestCaseWithMemoryTransport):
1728
1773
 
1729
1774
    def make_two_commit_repo(self):
2390
2435
            smart_repo.SmartServerRepositoryGetStream)
2391
2436
        self.assertHandlerEqual('Repository.get_stream_1.19',
2392
2437
            smart_repo.SmartServerRepositoryGetStream_1_19)
 
2438
        self.assertHandlerEqual('Repository.iter_revisions',
 
2439
            smart_repo.SmartServerRepositoryIterRevisions)
2393
2440
        self.assertHandlerEqual('Repository.has_revision',
2394
2441
            smart_repo.SmartServerRequestHasRevision)
2395
2442
        self.assertHandlerEqual('Repository.insert_stream',