Commit 020daaf4 authored by Jeremy Hylton's avatar Jeremy Hylton

Finish off the MVCC tests.

Drop several possible tasks that didn't seem relevant,
e.g. _p_independent() tests elsewhere should cover it just fine.
parent 7e376b24
...@@ -276,9 +276,9 @@ non-current revision to load. ...@@ -276,9 +276,9 @@ non-current revision to load.
>>> oid = r1["b"]._p_oid >>> oid = r1["b"]._p_oid
>>> ts.hooked[oid] = 1 >>> ts.hooked[oid] = 1
This test isn't quite rght yet, because it gets a ReadConflictError Once the oid is hooked, an invalidation will be delivered the next
instead of getting a non-current revision. Stil, it demonstrates that time it is activated. The code below activates the object, then
the basic mechanism for sending an invalidation during a load works. confirms that the hook worked and that the old state was retrieved.
>>> oid in cn1._invalidated >>> oid in cn1._invalidated
False False
...@@ -289,12 +289,45 @@ False ...@@ -289,12 +289,45 @@ False
True True
>>> ts.count >>> ts.count
1 1
>>> r1["b"].value
0
No earlier revision available
-----------------------------
We'll reuse the code from the example above, except that there will
only be a single revision of "b." As a result, the attempt to
activate "b" will result in a ReadConflictError.
>>> ts = TestStorage()
>>> db = DB(ts)
>>> cn1 = db.open()
>>> txn1 = cn1.setLocalTransaction()
>>> r1 = cn1.root()
>>> r1["a"] = MinPO(0)
>>> r1["b"] = MinPO(0)
>>> cn1.getTransaction().commit()
>>> cn1.cacheMinimize()
_p_independent() still has the desired effect. >>> oid = r1["b"]._p_oid
>>> ts.hooked[oid] = 1
Error cases: Once the oid is hooked, an invalidation will be delivered the next
- storage doesn't have an earlier revision time it is activated. The code below activates the object, then
- MVCC returns current revision confirms that the hook worked and that the old state was retrieved.
>>> oid in cn1._invalidated
False
>>> r1["b"]._p_state
-1
>>> r1["b"]._p_activate()
Traceback (most recent call last):
...
ReadConflictError: database read conflict error (oid 0000000000000002, class ZODB.tests.MinPO.MinPO)
>>> oid in cn1._invalidated
True
>>> ts.count
1
Cleanup Cleanup
------- -------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment