mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Test rollback in sync
This commit is contained in:
parent
4e3d351917
commit
8cbfb69691
1 changed files with 17 additions and 0 deletions
|
|
@ -415,6 +415,10 @@ def test_unicode_hrefs():
|
||||||
sync(a, b, status)
|
sync(a, b, status)
|
||||||
|
|
||||||
|
|
||||||
|
class ActionIntentionallyFailed(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SyncMachine(RuleBasedStateMachine):
|
class SyncMachine(RuleBasedStateMachine):
|
||||||
Status = Bundle('status')
|
Status = Bundle('status')
|
||||||
Storage = Bundle('storage')
|
Storage = Bundle('storage')
|
||||||
|
|
@ -446,6 +450,16 @@ class SyncMachine(RuleBasedStateMachine):
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
@rule(target=Storage, s=Storage)
|
||||||
|
def actions_fail(self, s):
|
||||||
|
def blowup(*a, **kw):
|
||||||
|
raise ActionIntentionallyFailed()
|
||||||
|
|
||||||
|
s.upload = blowup
|
||||||
|
s.update = blowup
|
||||||
|
s.delete = blowup
|
||||||
|
return s
|
||||||
|
|
||||||
@rule(target=Status)
|
@rule(target=Status)
|
||||||
def newstatus(self):
|
def newstatus(self):
|
||||||
return {}
|
return {}
|
||||||
|
|
@ -482,6 +496,7 @@ class SyncMachine(RuleBasedStateMachine):
|
||||||
assume(a is not b)
|
assume(a is not b)
|
||||||
old_items_a = self._get_items(a)
|
old_items_a = self._get_items(a)
|
||||||
old_items_b = self._get_items(b)
|
old_items_b = self._get_items(b)
|
||||||
|
old_status = deepcopy(status)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# If one storage is read-only, double-sync because changes don't
|
# If one storage is read-only, double-sync because changes don't
|
||||||
|
|
@ -490,6 +505,8 @@ class SyncMachine(RuleBasedStateMachine):
|
||||||
sync(a, b, status,
|
sync(a, b, status,
|
||||||
force_delete=force_delete,
|
force_delete=force_delete,
|
||||||
conflict_resolution=conflict_resolution)
|
conflict_resolution=conflict_resolution)
|
||||||
|
except ActionIntentionallyFailed:
|
||||||
|
assert status == old_status
|
||||||
except BothReadOnly:
|
except BothReadOnly:
|
||||||
assert a.read_only and b.read_only
|
assert a.read_only and b.read_only
|
||||||
assume(False)
|
assume(False)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue