Ensure updated items have the same UID (if any)

FastMail insists on this.
This commit is contained in:
Markus Unterwaditzer 2014-12-30 18:07:27 +01:00
parent 9ede54ed9b
commit e933f6db44
3 changed files with 14 additions and 14 deletions

View file

@ -41,7 +41,7 @@ TEL;TYPE=VOICE:412 605 0499
TEL;TYPE=FAX:412 605 0705
URL:http://www.example.com
X-SOMETHING:{r}
UID:{r}
UID:{uid}
END:VCARD'''
TASK_TEMPLATE = u'''BEGIN:VCALENDAR
@ -54,7 +54,7 @@ LAST-MODIFIED;VALUE=DATE-TIME:20140122T151338Z
SEQUENCE:2
SUMMARY:Book: Kowlani - Tödlicher Staub
X-SOMETHING:{r}
UID:{r}
UID:{uid}
END:VTODO
END:VCALENDAR'''
@ -64,7 +64,7 @@ DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
X-SOMETHING:{r}
UID:{r}
UID:{uid}
END:VEVENT'''
@ -76,7 +76,7 @@ END:VCALENDAR'''
SIMPLE_TEMPLATE = u'''BEGIN:FOO
UID:{r}
UID:{uid}
X-SOMETHING:{r}
HAHA:YES
END:FOO'''

View file

@ -19,10 +19,10 @@ from .. import EVENT_TEMPLATE, TASK_TEMPLATE, VCARD_TEMPLATE, \
assert_item_equals
def format_item(item_template):
def format_item(item_template, uid=None):
# assert that special chars are handled correctly.
r = '{}@vdirsyncer'.format(random.random())
return Item(item_template.format(r=r))
return Item(item_template.format(r=r, uid=uid or r))
class StorageTests(object):
@ -45,7 +45,7 @@ class StorageTests(object):
@pytest.fixture
def get_item(self, item_template):
return lambda: format_item(item_template)
return lambda **kw: format_item(item_template, **kw)
@pytest.fixture
def requires_collections(self):
@ -91,7 +91,7 @@ class StorageTests(object):
href, etag = s.upload(item)
assert_item_equals(s.get(href)[0], item)
new_item = get_item()
new_item = get_item(uid=item.uid)
new_etag = s.update(href, new_item, etag)
# See https://github.com/untitaker/vdirsyncer/issues/48
assert isinstance(new_etag, (bytes, text_type))

View file

@ -18,9 +18,9 @@ from .. import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, VCARD_TEMPLATE, \
normalize_item
_simple_split = [
VCARD_TEMPLATE.format(r=123),
VCARD_TEMPLATE.format(r=345),
VCARD_TEMPLATE.format(r=678)
VCARD_TEMPLATE.format(r=123, uid=123),
VCARD_TEMPLATE.format(r=345, uid=345),
VCARD_TEMPLATE.format(r=678, uid=678)
]
_simple_joined = u'\r\n'.join(
@ -115,8 +115,8 @@ def test_join_collection_vevents():
def test_split_collection_timezones():
items = [
BARE_EVENT_TEMPLATE.format(r=123),
BARE_EVENT_TEMPLATE.format(r=345)
BARE_EVENT_TEMPLATE.format(r=123, uid=123),
BARE_EVENT_TEMPLATE.format(r=345, uid=345)
]
timezone = (
@ -151,7 +151,7 @@ def test_split_collection_timezones():
def test_hash_item():
a = EVENT_TEMPLATE.format(r=1)
a = EVENT_TEMPLATE.format(r=1, uid=1)
b = u'\n'.join(line for line in a.splitlines()
if u'PRODID' not in line and u'VERSION' not in line)
assert vobject.hash_item(a) == vobject.hash_item(b)