/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-15 14:19:34 UTC
  • mfrom: (3172.5.9 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080115141934-3vujw0up5rc8e0gn
(robertc) Provide a smart server verb for get_parent_map against a
        RemoteRepository, (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
554
554
                         result)
555
555
 
556
556
 
 
557
class TestRepositoryGetGraph(TestRemoteRepository):
 
558
 
 
559
    def test_get_graph(self):
 
560
        # get_graph returns a graph with the repository as the
 
561
        # parents_provider.
 
562
        responses = []
 
563
        transport_path = 'quack'
 
564
        repo, client = self.setup_fake_client_and_repository(
 
565
            responses, transport_path)
 
566
        graph = repo.get_graph()
 
567
        self.assertEqual(graph._parents_provider, repo)
 
568
 
 
569
 
 
570
class TestRepositoryGetParentMap(TestRemoteRepository):
 
571
 
 
572
    def test_get_parent_map_caching(self):
 
573
        # get_parent_map returns from cache until unlock()
 
574
        # setup a reponse with two revisions
 
575
        r1 = u'\u0e33'.encode('utf8')
 
576
        r2 = u'\u0dab'.encode('utf8')
 
577
        lines = [' '.join([r2, r1]), r1]
 
578
        encoded_body = '\n'.join(lines)
 
579
        responses = [(('ok', ), encoded_body), (('ok', ), encoded_body)]
 
580
 
 
581
        transport_path = 'quack'
 
582
        repo, client = self.setup_fake_client_and_repository(
 
583
            responses, transport_path)
 
584
        repo.lock_read()
 
585
        graph = repo.get_graph()
 
586
        parents = graph.get_parent_map([r2])
 
587
        self.assertEqual({r2: (r1,)}, parents)
 
588
        # locking and unlocking deeper should not reset
 
589
        repo.lock_read()
 
590
        repo.unlock()
 
591
        parents = graph.get_parent_map([r1])
 
592
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
 
593
        self.assertEqual(
 
594
            [('call_expecting_body', 'Repository.get_parent_map',
 
595
             ('quack/', r2))],
 
596
            client._calls)
 
597
        repo.unlock()
 
598
        # now we call again, and it should use the second response.
 
599
        repo.lock_read()
 
600
        graph = repo.get_graph()
 
601
        parents = graph.get_parent_map([r1])
 
602
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
 
603
        self.assertEqual(
 
604
            [('call_expecting_body', 'Repository.get_parent_map',
 
605
              ('quack/', r2)),
 
606
             ('call_expecting_body', 'Repository.get_parent_map',
 
607
              ('quack/', r1))
 
608
            ],
 
609
            client._calls)
 
610
        repo.unlock()
 
611
 
 
612
 
557
613
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
558
614
    
559
615
    def test_null_revision(self):