mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Factor out duplicate UID strategies
This commit is contained in:
parent
9081284f02
commit
2beb854157
3 changed files with 12 additions and 8 deletions
|
|
@ -74,3 +74,11 @@ printable_characters_strategy = st.text(
|
||||||
'Cc', 'Cs'
|
'Cc', 'Cs'
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
uid_strategy = st.text(
|
||||||
|
st.characters(blacklist_categories=(
|
||||||
|
'Zs', 'Zl', 'Zp',
|
||||||
|
'Cc', 'Cs'
|
||||||
|
)),
|
||||||
|
min_size=1
|
||||||
|
).filter(lambda x: x.strip() == x)
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,14 @@
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from hypothesis import given, settings
|
from hypothesis import given, settings
|
||||||
import hypothesis.strategies as st
|
|
||||||
|
from tests import uid_strategy
|
||||||
|
|
||||||
from vdirsyncer.repair import repair_storage
|
from vdirsyncer.repair import repair_storage
|
||||||
from vdirsyncer.storage.memory import MemoryStorage
|
from vdirsyncer.storage.memory import MemoryStorage
|
||||||
from vdirsyncer.utils import href_safe
|
from vdirsyncer.utils import href_safe
|
||||||
from vdirsyncer.utils.vobject import Item
|
from vdirsyncer.utils.vobject import Item
|
||||||
|
|
||||||
uid_strategy = st.text(st.characters(blacklist_categories=(
|
|
||||||
'Zs', 'Zl', 'Zp',
|
|
||||||
'Cc', 'Cs'
|
|
||||||
)))
|
|
||||||
|
|
||||||
|
|
||||||
@given(uid=uid_strategy)
|
@given(uid=uid_strategy)
|
||||||
@settings(perform_health_check=False) # Using the random module for UIDs
|
@settings(perform_health_check=False) # Using the random module for UIDs
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ from vdirsyncer.storage.memory import MemoryStorage
|
||||||
from vdirsyncer.sync import BothReadOnly, IdentConflict, StorageEmpty, \
|
from vdirsyncer.sync import BothReadOnly, IdentConflict, StorageEmpty, \
|
||||||
SyncConflict, sync
|
SyncConflict, sync
|
||||||
|
|
||||||
from . import assert_item_equals, blow_up
|
from . import assert_item_equals, blow_up, uid_strategy
|
||||||
|
|
||||||
|
|
||||||
def empty_storage(x):
|
def empty_storage(x):
|
||||||
|
|
@ -409,7 +409,7 @@ class SyncMachine(RuleBasedStateMachine):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@rule(target=Storage, storage=Storage,
|
@rule(target=Storage, storage=Storage,
|
||||||
uid=st.text(min_size=1),
|
uid=uid_strategy,
|
||||||
etag=st.text())
|
etag=st.text())
|
||||||
def upload(self, storage, uid, etag):
|
def upload(self, storage, uid, etag):
|
||||||
item = Item(u'UID:{}'.format(uid))
|
item = Item(u'UID:{}'.format(uid))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue