~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-12-14 21:50:54 UTC
  • mfrom: (6282.6.43 hpss-get-inventories)
  • Revision ID: pqm@pqm.ubuntu.com-20111214215054-kbzhlka9gtbd4zd7
(jelmer) Add HPSS call for retrieving inventories. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    bzrdir,
33
33
    errors,
34
34
    gpg,
 
35
    inventory_delta,
35
36
    tests,
36
37
    transport,
37
38
    urlutils,
2565
2566
            smart_repo.SmartServerRepositoryAbortWriteGroup)
2566
2567
        self.assertHandlerEqual('VersionedFileRepository.get_serializer_format',
2567
2568
            smart_repo.SmartServerRepositoryGetSerializerFormat)
 
2569
        self.assertHandlerEqual('VersionedFileRepository.get_inventories',
 
2570
            smart_repo.SmartServerRepositoryGetInventories)
2568
2571
        self.assertHandlerEqual('Transport.is_readonly',
2569
2572
            smart_req.SmartServerIsReadonly)
2570
2573
 
2630
2633
            smart_req.SuccessfulSmartServerResponse(('ok', ), ),
2631
2634
            request.do_body(''))
2632
2635
 
 
2636
 
 
2637
class TestSmartServerRepositoryGetInventories(tests.TestCaseWithTransport):
 
2638
 
 
2639
    def _get_serialized_inventory_delta(self, repository, base_revid, revid):
 
2640
        base_inv = repository.revision_tree(base_revid).inventory
 
2641
        inv = repository.revision_tree(revid).inventory
 
2642
        inv_delta = inv._make_delta(base_inv)
 
2643
        serializer = inventory_delta.InventoryDeltaSerializer(True, False)
 
2644
        return "".join(serializer.delta_to_lines(base_revid, revid, inv_delta))
 
2645
 
 
2646
    def test_single(self):
 
2647
        backing = self.get_transport()
 
2648
        request = smart_repo.SmartServerRepositoryGetInventories(backing)
 
2649
        t = self.make_branch_and_tree('.', format='2a')
 
2650
        self.addCleanup(t.lock_write().unlock)
 
2651
        self.build_tree_contents([("file", "somecontents")])
 
2652
        t.add(["file"], ["thefileid"])
 
2653
        t.commit(rev_id='somerev', message="add file")
 
2654
        self.assertIs(None, request.execute('', 'unordered'))
 
2655
        response = request.do_body("somerev\n")
 
2656
        self.assertTrue(response.is_successful())
 
2657
        self.assertEquals(response.args, ("ok", ))
 
2658
        stream = [('inventory-deltas', [
 
2659
            versionedfile.FulltextContentFactory('somerev', None, None,
 
2660
                self._get_serialized_inventory_delta(
 
2661
                    t.branch.repository, 'null:', 'somerev'))])]
 
2662
        fmt = bzrdir.format_registry.get('2a')().repository_format
 
2663
        self.assertEquals(
 
2664
            "".join(response.body_stream),
 
2665
            "".join(smart_repo._stream_to_byte_stream(stream, fmt)))
 
2666
 
 
2667
    def test_empty(self):
 
2668
        backing = self.get_transport()
 
2669
        request = smart_repo.SmartServerRepositoryGetInventories(backing)
 
2670
        t = self.make_branch_and_tree('.', format='2a')
 
2671
        self.addCleanup(t.lock_write().unlock)
 
2672
        self.build_tree_contents([("file", "somecontents")])
 
2673
        t.add(["file"], ["thefileid"])
 
2674
        t.commit(rev_id='somerev', message="add file")
 
2675
        self.assertIs(None, request.execute('', 'unordered'))
 
2676
        response = request.do_body("")
 
2677
        self.assertTrue(response.is_successful())
 
2678
        self.assertEquals(response.args, ("ok", ))
 
2679
        self.assertEquals("".join(response.body_stream),
 
2680
            "Bazaar pack format 1 (introduced in 0.18)\nB54\n\nBazaar repository format 2a (needs bzr 1.16 or later)\nE")