Commit 0a7ee5ce authored by Adam Groszer's avatar Adam Groszer

fixed ResolveableWhenStateDoesNotChange, changed...

fixed ResolveableWhenStateDoesNotChange, changed show_tryToResolveConflict_log_output to check both cases
parent db98563c
...@@ -39,7 +39,7 @@ def tearDown(test): ...@@ -39,7 +39,7 @@ def tearDown(test):
class ResolveableWhenStateDoesNotChange(persistent.Persistent): class ResolveableWhenStateDoesNotChange(persistent.Persistent):
def _p_resolveConflict(old, committed, new): def _p_resolveConflict(self, old, committed, new):
raise ZODB.POSException.ConflictError raise ZODB.POSException.ConflictError
class Unresolvable(persistent.Persistent): class Unresolvable(persistent.Persistent):
...@@ -292,6 +292,13 @@ And load the pickle: ...@@ -292,6 +292,13 @@ And load the pickle:
>>> db2.close() >>> db2.close()
""" """
class FailHard(persistent.Persistent):
def _p_resolveConflict(self, old, committed, new):
raise RuntimeError("epic fail")
def show_tryToResolveConflict_log_output(): def show_tryToResolveConflict_log_output():
""" """
Verify output generated by tryToResolveConflict in the logs Verify output generated by tryToResolveConflict in the logs
...@@ -299,7 +306,7 @@ def show_tryToResolveConflict_log_output(): ...@@ -299,7 +306,7 @@ def show_tryToResolveConflict_log_output():
>>> db = ZODB.DB('t.fs') # FileStorage! >>> db = ZODB.DB('t.fs') # FileStorage!
>>> storage = db.storage >>> storage = db.storage
>>> conn = db.open() >>> conn = db.open()
>>> conn.root.x = ResolveableWhenStateDoesNotChange() >>> conn.root.x = FailHard()
>>> conn.root.x.v = 1 >>> conn.root.x.v = 1
>>> transaction.commit() >>> transaction.commit()
>>> serial1 = conn.root.x._p_serial >>> serial1 = conn.root.x._p_serial
...@@ -315,7 +322,7 @@ Install a log handler to be able to show log entries ...@@ -315,7 +322,7 @@ Install a log handler to be able to show log entries
>>> handler = InstalledHandler('ZODB.ConflictResolution', >>> handler = InstalledHandler('ZODB.ConflictResolution',
... level=logging.DEBUG) ... level=logging.DEBUG)
We conflict if both the committed and new are different than the original: Content fails hard on conflict resolution:
>>> p = storage.tryToResolveConflict( >>> p = storage.tryToResolveConflict(
... oid, serial2, serial1, storage.loadSerial(oid, serial2)) ... oid, serial2, serial1, storage.loadSerial(oid, serial2))
...@@ -324,7 +331,7 @@ We conflict if both the committed and new are different than the original: ...@@ -324,7 +331,7 @@ We conflict if both the committed and new are different than the original:
... ...
ConflictError: database conflict error (oid 0x01, ... ConflictError: database conflict error (oid 0x01, ...
If content doesn't support conflict resolution: Content doesn't support conflict resolution:
>>> conn.root.y = Unresolvable() >>> conn.root.y = Unresolvable()
>>> conn.root.y.v = 1 >>> conn.root.y.v = 1
......
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