From 12098bcc9da685a09e42f60fd6420a609b838a4f Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 10 Jan 2015 22:06:56 +0100 Subject: [PATCH] Add testcase for moved hrefs. --- tests/test_sync.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/test_sync.py b/tests/test_sync.py index 493b6b0..b8eb7a0 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -15,7 +15,7 @@ from vdirsyncer.storage.memory import MemoryStorage from vdirsyncer.sync import BothReadOnly, IdentConflict, StorageEmpty, \ SyncConflict, sync -from . import assert_item_equals, normalize_item +from . import assert_item_equals, blow_up, normalize_item def empty_storage(x): @@ -282,3 +282,26 @@ def test_ident_conflict(sync_inbetween): with pytest.raises(IdentConflict): sync(a, b, status) + + +def test_moved_href(): + ''' + Concrete application: ppl_ stores contact aliases in filenames, which means + item's hrefs get changed. Vdirsyncer doesn't synchronize this data, but + also shouldn't do things like deleting and re-uploading to the server. + + .. _ppl: http://ppladdressbook.org/ + ''' + a = MemoryStorage() + b = MemoryStorage() + status = {} + href, etag = a.upload(Item(u'UID:haha')) + sync(a, b, status) + + b.items['lol'] = b.items.pop('haha') + a.delete = a.update = a.upload = blow_up + + sync(a, b, status) + assert len(status) == 1 + assert len(list(a.list())) == len(list(b.list())) == 1 + assert status['haha'][2] == 'haha'