mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-24 14:27:41 +00:00
Test read_only in sync
This commit is contained in:
parent
b9f3ca3581
commit
cbb1967017
1 changed files with 13 additions and 6 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
from hypothesis import assume
|
||||||
from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule
|
from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule
|
||||||
import hypothesis.strategies as st
|
import hypothesis.strategies as st
|
||||||
|
|
||||||
|
|
@ -399,9 +400,11 @@ class SyncMachine(RuleBasedStateMachine):
|
||||||
Status = Bundle('status')
|
Status = Bundle('status')
|
||||||
Storage = Bundle('storage')
|
Storage = Bundle('storage')
|
||||||
|
|
||||||
@rule(target=Storage)
|
@rule(target=Storage, read_only=st.booleans())
|
||||||
def newstorage(self):
|
def newstorage(self, read_only):
|
||||||
return MemoryStorage()
|
s = MemoryStorage()
|
||||||
|
s.read_only = read_only
|
||||||
|
return s
|
||||||
|
|
||||||
@rule(target=Status)
|
@rule(target=Status)
|
||||||
def newstatus(self):
|
def newstatus(self):
|
||||||
|
|
@ -428,9 +431,13 @@ class SyncMachine(RuleBasedStateMachine):
|
||||||
)
|
)
|
||||||
def sync(self, status, a, b, force_delete, conflict_resolution):
|
def sync(self, status, a, b, force_delete, conflict_resolution):
|
||||||
try:
|
try:
|
||||||
sync(a, b, status,
|
for _ in range(2 if a.read_only or b.read_only else 1):
|
||||||
force_delete=force_delete,
|
sync(a, b, status,
|
||||||
conflict_resolution=conflict_resolution)
|
force_delete=force_delete,
|
||||||
|
conflict_resolution=conflict_resolution)
|
||||||
|
except BothReadOnly:
|
||||||
|
assert a.read_only and b.read_only
|
||||||
|
assume(False)
|
||||||
except StorageEmpty:
|
except StorageEmpty:
|
||||||
if force_delete:
|
if force_delete:
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue