174
def load_before_base_storage_current():
176
Here we'll exercise that DemoStorage's loadBefore method works
177
properly when deferring to a record that is current in the
181
>>> import transaction
183
>>> import ZODB.DemoStorage
184
>>> import ZODB.MappingStorage
185
>>> import ZODB.utils
187
>>> base = ZODB.MappingStorage.MappingStorage()
188
>>> basedb = ZODB.DB(base)
189
>>> conn = basedb.open()
190
>>> conn.root()['foo'] = 'bar'
191
>>> transaction.commit()
193
>>> storage = ZODB.DemoStorage.DemoStorage(base=base)
194
>>> db = ZODB.DB(storage)
196
>>> conn.root()['foo'] = 'baz'
197
>>> time.sleep(.1) # Windows has a low-resolution clock
198
>>> transaction.commit()
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
206
>>> base_current == base_record[:2]
209
>>> t = storage.loadBefore(oid, tid)
211
The data and tid are the values from the base storage, but the
212
next tid is from changes.
214
>>> t[:2] == base_record[:2]
216
>>> t[-1] == storage.changes.load(oid)[1]
175
224
def test_suite():
176
225
suite = unittest.TestSuite((