~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testidentitymap.py

  • Committer: Robert Collins
  • Date: 2005-10-11 02:52:47 UTC
  • mfrom: (1417.1.13)
  • Revision ID: robertc@robertcollins.net-20051011025247-4b95466bb6509385
merge in revision-history caching, and tuning of fetch to not retrieve more data than needed when nothing needs to be pulled

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        self.assertRaises(errors.BzrError, map.add_weave, "id", weave)
47
47
        self.assertEqual(weave, map.find_weave("id"))
48
48
 
 
49
    def test_remove_object(self):
 
50
        map = identitymap.IdentityMap()
 
51
        weave = "foo"
 
52
        map.add_weave("id", weave)
 
53
        map.remove_object(weave)
 
54
        map.add_weave("id", weave)
 
55
        rev_history = [1]
 
56
        map.add_revision_history(rev_history)
 
57
        map.remove_object(rev_history)
 
58
 
 
59
    def test_add_revision_history(self):
 
60
        map = identitymap.IdentityMap()
 
61
        rev_history = [1,2,3]
 
62
        map.add_revision_history(rev_history)
 
63
        self.assertEqual(rev_history, map.find_revision_history())
 
64
 
 
65
    def test_double_add_revision_history(self):
 
66
        map = identitymap.IdentityMap()
 
67
        revision_history = [1]
 
68
        map.add_revision_history(revision_history)
 
69
        self.assertRaises(errors.BzrError,
 
70
                          map.add_revision_history,
 
71
                          revision_history)
 
72
        self.assertEqual(revision_history, map.find_revision_history())
 
73
 
49
74
 
50
75
class TestNullIdentityMap(TestCase):
51
76
 
68
93
        map.add_weave("id", weave)
69
94
        self.assertEqual(None, map.find_weave("id"))
70
95
        
 
96
    def test_null_identity_map_has_no_remove(self):
 
97
        map = identitymap.NullIdentityMap()
 
98
        self.assertEqual(None, getattr(map, 'remove_object', None))
 
99
 
 
100
    def test_add_revision_history(self):
 
101
        map = identitymap.NullIdentityMap()
 
102
        rev_history = [1,2,3]
 
103
        map.add_revision_history(rev_history)
 
104
        self.assertEqual(None, map.find_revision_history())
 
105
 
 
106
    def test_double_add_revision_history(self):
 
107
        map = identitymap.NullIdentityMap()
 
108
        revision_history = [1]
 
109
        map.add_revision_history(revision_history)
 
110
        map.add_revision_history(revision_history)
 
111
        self.assertEqual(None, map.find_revision_history())