~ubuntu-branches/ubuntu/quantal/zodb/quantal

« back to all changes in this revision

Viewing changes to src/ZODB/tests/testDemoStorage.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella, Brian Sutherland, Fabio Tranchitella
  • Date: 2010-01-05 22:22:35 UTC
  • mfrom: (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100105222235-z2xg4h60ru3e891t
Tags: 1:3.9.4-1
[ Brian Sutherland ]
* debian/tests/all: Test the correct python modules.

[ Fabio Tranchitella ]
* New upstream release.
* Convert to debhelper 7 and the pydeb dh7 extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
 
172
172
    """
173
173
 
 
174
def load_before_base_storage_current():
 
175
    """
 
176
    Here we'll exercise that DemoStorage's loadBefore method works
 
177
    properly when deferring to a record that is current in the
 
178
    base storage.
 
179
 
 
180
    >>> import time
 
181
    >>> import transaction
 
182
    >>> import ZODB.DB
 
183
    >>> import ZODB.DemoStorage
 
184
    >>> import ZODB.MappingStorage
 
185
    >>> import ZODB.utils
 
186
 
 
187
    >>> base = ZODB.MappingStorage.MappingStorage()
 
188
    >>> basedb = ZODB.DB(base)
 
189
    >>> conn = basedb.open()
 
190
    >>> conn.root()['foo'] = 'bar'
 
191
    >>> transaction.commit()
 
192
    >>> conn.close()
 
193
    >>> storage = ZODB.DemoStorage.DemoStorage(base=base)
 
194
    >>> db = ZODB.DB(storage)
 
195
    >>> conn = db.open()
 
196
    >>> conn.root()['foo'] = 'baz'
 
197
    >>> time.sleep(.1) # Windows has a low-resolution clock
 
198
    >>> transaction.commit()
 
199
 
 
200
    >>> oid = ZODB.utils.z64
 
201
    >>> base_current = storage.base.load(oid)
 
202
    >>> tid = ZODB.utils.p64(ZODB.utils.u64(base_current[1]) + 1)
 
203
    >>> base_record = storage.base.loadBefore(oid, tid)
 
204
    >>> base_record[-1] is None
 
205
    True
 
206
    >>> base_current == base_record[:2]
 
207
    True
 
208
 
 
209
    >>> t = storage.loadBefore(oid, tid)
 
210
 
 
211
    The data and tid are the values from the base storage, but the
 
212
    next tid is from changes.
 
213
 
 
214
    >>> t[:2] == base_record[:2]
 
215
    True
 
216
    >>> t[-1] == storage.changes.load(oid)[1]
 
217
    True
 
218
 
 
219
    >>> conn.close()
 
220
    >>> db.close()
 
221
    >>> base.close()
 
222
    """
174
223
 
175
224
def test_suite():
176
225
    suite = unittest.TestSuite((