~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transactions.py

  • Committer: Martin Pool
  • Date: 2006-03-16 20:20:32 UTC
  • mto: (1615.1.1 bzr.mbp.integration)
  • mto: This revision was merged to the branch mainline in revision 1616.
  • Revision ID: mbp@sourcefrog.net-20060316202032-d044f29e7d81b333
Update version numbers

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""Tests for the behaviour of the Transaction concept in bzr."""
19
19
 
60
60
        self.transaction.register_clean("anobject")
61
61
 
62
62
    def test_register_dirty_raises(self):
63
 
        self.assertRaises(errors.ReadOnlyError,
 
63
        self.assertRaises(errors.ReadOnlyError, 
64
64
                          self.transaction.register_dirty,"anobject")
65
 
 
 
65
    
66
66
    def test_map(self):
67
67
        self.assertNotEqual(None, getattr(self.transaction, "map", None))
68
 
 
 
68
    
69
69
    def test_add_and_get(self):
70
70
        weave = "a weave"
71
71
        self.transaction.map.add_weave("id", weave)
99
99
        # its not a weakref system
100
100
        self.assertEqual(DummyWeave("another weave"),
101
101
                         self.transaction.map.find_weave("id"))
102
 
 
 
102
        
103
103
    def test_small_cache(self):
104
104
        self.transaction.set_cache_size(1)
105
105
        # add an object, should not fall right out if there are no references
139
139
        self.assertEqual(DummyWeave('a weave'),
140
140
                         self.transaction.map.find_weave("id"))
141
141
 
 
142
    def test_precious_revision_history(self):
 
143
        """Disabled test until revision-history is a real object."""
 
144
        print "Disabled: test_precious_revision_history"
 
145
        return
 
146
        self.transaction.set_cache_size(0)
 
147
        history = []
 
148
        self.transaction.map.add_revision_history(history)
 
149
        self.assertEqual(history, self.transaction.map.find_revision_history())
 
150
        history = None
 
151
        # add an object, should not fall out even with no references.
 
152
        self.transaction.register_clean(
 
153
            self.transaction.map.find_revision_history(), precious=True)
 
154
        self.assertEqual([], self.transaction.map.find_revision_history())
 
155
 
142
156
    def test_writable(self):
143
157
        self.assertFalse(self.transaction.writeable())
144
158
 
151
165
    def test_register_clean(self):
152
166
        transaction = transactions.PassThroughTransaction()
153
167
        transaction.register_clean("anobject")
154
 
 
 
168
    
155
169
    def test_register_dirty(self):
156
170
        transaction = transactions.PassThroughTransaction()
157
171
        transaction.register_dirty("anobject")
158
 
 
 
172
    
159
173
    def test_map(self):
160
174
        transaction = transactions.PassThroughTransaction()
161
175
        self.assertNotEqual(None, getattr(transaction, "map", None))
162
 
 
 
176
    
163
177
    def test_add_and_get(self):
164
178
        transaction = transactions.PassThroughTransaction()
165
179
        weave = "a weave"
166
180
        transaction.map.add_weave("id", weave)
167
181
        self.assertEqual(None, transaction.map.find_weave("id"))
168
 
 
 
182
        
169
183
    def test_finish_returns(self):
170
184
        transaction = transactions.PassThroughTransaction()
171
185
        transaction.finish()
189
203
    def test_writable(self):
190
204
        transaction = transactions.PassThroughTransaction()
191
205
        self.assertTrue(transaction.writeable())
192
 
 
 
206
        
193
207
 
194
208
class TestWriteTransaction(TestCase):
195
209
 
199
213
 
200
214
    def test_register_clean(self):
201
215
        self.transaction.register_clean("anobject")
202
 
 
 
216
    
203
217
    def test_register_dirty(self):
204
218
        self.transaction.register_dirty("anobject")
205
 
 
 
219
    
206
220
    def test_map(self):
207
221
        self.assertNotEqual(None, getattr(self.transaction, "map", None))
208
 
 
 
222
    
209
223
    def test_add_and_get(self):
210
224
        weave = "a weave"
211
225
        self.transaction.map.add_weave("id", weave)
212
226
        self.assertEqual(weave, self.transaction.map.find_weave("id"))
213
 
 
 
227
        
214
228
    def test_finish_returns(self):
215
229
        self.transaction.finish()
216
230
 
250
264
        weave = None
251
265
        self.transaction.register_dirty(self.transaction.map.find_weave("id"))
252
266
        self.assertNotEqual(None, self.transaction.map.find_weave("id"))
253
 
 
 
267
    
254
268
    def test_clean_to_dirty(self):
255
269
        # a clean object may become dirty.
256
270
        weave = DummyWeave('A weave')