~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transactions.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-13 14:33:10 UTC
  • mto: (2733.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2734.
  • Revision ID: ian.clatworthy@internode.on.net-20070813143310-twhj4la0qnupvze8
Added Quick Start Summary

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2005 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
 
 
20
# import system imports here
 
21
import os
 
22
import sys
 
23
 
20
24
#import bzrlib specific imports here
21
25
import bzrlib.errors as errors
22
 
from bzrlib.tests import TestCase
 
26
from bzrlib.tests import TestCase, TestCaseInTempDir
23
27
import bzrlib.transactions as transactions
24
28
 
25
29
 
56
60
        self.transaction.register_clean("anobject")
57
61
 
58
62
    def test_register_dirty_raises(self):
59
 
        self.assertRaises(errors.ReadOnlyError,
 
63
        self.assertRaises(errors.ReadOnlyError, 
60
64
                          self.transaction.register_dirty,"anobject")
61
 
 
 
65
    
62
66
    def test_map(self):
63
67
        self.assertNotEqual(None, getattr(self.transaction, "map", None))
64
 
 
 
68
    
65
69
    def test_add_and_get(self):
66
70
        weave = "a weave"
67
71
        self.transaction.map.add_weave("id", weave)
95
99
        # its not a weakref system
96
100
        self.assertEqual(DummyWeave("another weave"),
97
101
                         self.transaction.map.find_weave("id"))
98
 
 
 
102
        
99
103
    def test_small_cache(self):
100
104
        self.transaction.set_cache_size(1)
101
105
        # add an object, should not fall right out if there are no references
147
151
    def test_register_clean(self):
148
152
        transaction = transactions.PassThroughTransaction()
149
153
        transaction.register_clean("anobject")
150
 
 
 
154
    
151
155
    def test_register_dirty(self):
152
156
        transaction = transactions.PassThroughTransaction()
153
157
        transaction.register_dirty("anobject")
154
 
 
 
158
    
155
159
    def test_map(self):
156
160
        transaction = transactions.PassThroughTransaction()
157
161
        self.assertNotEqual(None, getattr(transaction, "map", None))
158
 
 
 
162
    
159
163
    def test_add_and_get(self):
160
164
        transaction = transactions.PassThroughTransaction()
161
165
        weave = "a weave"
162
166
        transaction.map.add_weave("id", weave)
163
167
        self.assertEqual(None, transaction.map.find_weave("id"))
164
 
 
 
168
        
165
169
    def test_finish_returns(self):
166
170
        transaction = transactions.PassThroughTransaction()
167
171
        transaction.finish()
185
189
    def test_writable(self):
186
190
        transaction = transactions.PassThroughTransaction()
187
191
        self.assertTrue(transaction.writeable())
188
 
 
 
192
        
189
193
 
190
194
class TestWriteTransaction(TestCase):
191
195
 
195
199
 
196
200
    def test_register_clean(self):
197
201
        self.transaction.register_clean("anobject")
198
 
 
 
202
    
199
203
    def test_register_dirty(self):
200
204
        self.transaction.register_dirty("anobject")
201
 
 
 
205
    
202
206
    def test_map(self):
203
207
        self.assertNotEqual(None, getattr(self.transaction, "map", None))
204
 
 
 
208
    
205
209
    def test_add_and_get(self):
206
210
        weave = "a weave"
207
211
        self.transaction.map.add_weave("id", weave)
208
212
        self.assertEqual(weave, self.transaction.map.find_weave("id"))
209
 
 
 
213
        
210
214
    def test_finish_returns(self):
211
215
        self.transaction.finish()
212
216
 
246
250
        weave = None
247
251
        self.transaction.register_dirty(self.transaction.map.find_weave("id"))
248
252
        self.assertNotEqual(None, self.transaction.map.find_weave("id"))
249
 
 
 
253
    
250
254
    def test_clean_to_dirty(self):
251
255
        # a clean object may become dirty.
252
256
        weave = DummyWeave('A weave')