~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transactions.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-22 14:12:18 UTC
  • mfrom: (6155.3.1 jam)
  • Revision ID: pqm@pqm.ubuntu.com-20110922141218-86s4uu6nqvourw4f
(jameinel) Cleanup comments bzrlib/smart/__init__.py (John A Meinel)

Show diffs side-by-side

added added

removed removed

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