/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: Martin Pool
  • Date: 2009-03-23 07:37:34 UTC
  • mto: This revision was merged to the branch mainline in revision 4189.
  • Revision ID: mbp@sourcefrog.net-20090323073734-5puelztfh6kts6ts
Undelete TestRepositoryGetRevisionGraph but make it use private client methods to simulate old clients

Show diffs side-by-side

added added

removed removed

Lines of Context:
1629
1629
        self.assertEqual({'rev1': ('null:',)}, graph.get_parent_map(['rev1']))
1630
1630
 
1631
1631
 
 
1632
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
 
1633
 
 
1634
    def test_null_revision(self):
 
1635
        # a null revision has the predictable result {}, we should have no wire
 
1636
        # traffic when calling it with this argument
 
1637
        transport_path = 'empty'
 
1638
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1639
        client.add_success_response('notused')
 
1640
        # actual RemoteRepository.get_revision_graph is gone, but there's an
 
1641
        # equivalent private method for testing
 
1642
        result = repo._get_revision_graph(NULL_REVISION)
 
1643
        self.assertEqual([], client._calls)
 
1644
        self.assertEqual({}, result)
 
1645
 
 
1646
    def test_none_revision(self):
 
1647
        # with none we want the entire graph
 
1648
        r1 = u'\u0e33'.encode('utf8')
 
1649
        r2 = u'\u0dab'.encode('utf8')
 
1650
        lines = [' '.join([r2, r1]), r1]
 
1651
        encoded_body = '\n'.join(lines)
 
1652
 
 
1653
        transport_path = 'sinhala'
 
1654
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1655
        client.add_success_response_with_body(encoded_body, 'ok')
 
1656
        # actual RemoteRepository.get_revision_graph is gone, but there's an
 
1657
        # equivalent private method for testing
 
1658
        result = repo._get_revision_graph(None)
 
1659
        self.assertEqual(
 
1660
            [('call_expecting_body', 'Repository.get_revision_graph',
 
1661
             ('sinhala/', ''))],
 
1662
            client._calls)
 
1663
        self.assertEqual({r1: (), r2: (r1, )}, result)
 
1664
 
 
1665
    def test_specific_revision(self):
 
1666
        # with a specific revision we want the graph for that
 
1667
        # with none we want the entire graph
 
1668
        r11 = u'\u0e33'.encode('utf8')
 
1669
        r12 = u'\xc9'.encode('utf8')
 
1670
        r2 = u'\u0dab'.encode('utf8')
 
1671
        lines = [' '.join([r2, r11, r12]), r11, r12]
 
1672
        encoded_body = '\n'.join(lines)
 
1673
 
 
1674
        transport_path = 'sinhala'
 
1675
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1676
        client.add_success_response_with_body(encoded_body, 'ok')
 
1677
        result = repo._get_revision_graph(r2)
 
1678
        self.assertEqual(
 
1679
            [('call_expecting_body', 'Repository.get_revision_graph',
 
1680
             ('sinhala/', r2))],
 
1681
            client._calls)
 
1682
        self.assertEqual({r11: (), r12: (), r2: (r11, r12), }, result)
 
1683
 
 
1684
    def test_no_such_revision(self):
 
1685
        revid = '123'
 
1686
        transport_path = 'sinhala'
 
1687
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1688
        client.add_error_response('nosuchrevision', revid)
 
1689
        # also check that the right revision is reported in the error
 
1690
        self.assertRaises(errors.NoSuchRevision,
 
1691
            repo._get_revision_graph, revid)
 
1692
        self.assertEqual(
 
1693
            [('call_expecting_body', 'Repository.get_revision_graph',
 
1694
             ('sinhala/', revid))],
 
1695
            client._calls)
 
1696
 
 
1697
    def test_unexpected_error(self):
 
1698
        revid = '123'
 
1699
        transport_path = 'sinhala'
 
1700
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1701
        client.add_error_response('AnUnexpectedError')
 
1702
        e = self.assertRaises(errors.UnknownErrorFromSmartServer,
 
1703
            repo._get_revision_graph, revid)
 
1704
        self.assertEqual(('AnUnexpectedError',), e.error_tuple)
 
1705
 
 
1706
 
1632
1707
class TestRepositoryIsShared(TestRemoteRepository):
1633
1708
 
1634
1709
    def test_is_shared(self):