Test read_only in sync

This commit is contained in:
Markus Unterwaditzer 2016-04-29 19:53:43 +02:00
parent b9f3ca3581
commit cbb1967017

View file

@ -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