本文整理汇总了Python中vdirsyncer.storage.memory.MemoryStorage.list方法的典型用法代码示例。如果您正苦于以下问题:Python MemoryStorage.list方法的具体用法?Python MemoryStorage.list怎么用?Python MemoryStorage.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vdirsyncer.storage.memory.MemoryStorage
的用法示例。
在下文中一共展示了MemoryStorage.list方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_moved_href
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
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')
# The sync algorithm should prefetch `lol`, see that it's the same ident
# and not do anything else.
a.get_multi = blow_up # Absolutely no prefetch on A
# No actual sync actions
a.delete = a.update = a.upload = b.delete = b.update = b.upload = blow_up
sync(a, b, status)
assert len(status) == 1
assert len(list(a.list())) == len(list(b.list())) == 1
assert status['haha'][1]['href'] == 'lol'
old_status = deepcopy(status)
# Further sync should be a noop. Not even prefetching should occur.
b.get_multi = blow_up
sync(a, b, status)
assert old_status == status
assert len(list(a.list())) == len(list(b.list())) == 1
示例2: test_no_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_no_uids():
a = MemoryStorage()
b = MemoryStorage()
href_a, _ = a.upload(Item(u'ASDF'))
href_b, _ = b.upload(Item(u'FOOBAR'))
status = {}
sync(a, b, status)
a_items = set(a.get(href)[0].raw for href, etag in a.list())
b_items = set(b.get(href)[0].raw for href, etag in b.list())
assert a_items == b_items == {u'ASDF', u'FOOBAR'}
示例3: test_updated_and_deleted
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_updated_and_deleted():
a = MemoryStorage()
b = MemoryStorage()
href_a, etag_a = a.upload(Item(u"UID:1"))
status = {}
sync(a, b, status, force_delete=True)
(href_b, etag_b), = b.list()
b.delete(href_b, etag_b)
a.update(href_a, Item(u"UID:1\nupdated"), etag_a)
sync(a, b, status, force_delete=True)
assert len(list(a.list())) == len(list(b.list())) == 1
示例4: test_repair_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_repair_uids():
s = MemoryStorage()
s.items = {
'one': ('asdf', Item(u'BEGIN:VCARD\nFN:Hans\nUID:asdf\nEND:VCARD')),
'two': ('asdf', Item(u'BEGIN:VCARD\nFN:Peppi\nUID:asdf\nEND:VCARD'))
}
uid1, uid2 = [s.get(href)[0].uid for href, etag in s.list()]
assert uid1 == uid2
repair_storage(s)
uid1, uid2 = [s.get(href)[0].uid for href, etag in s.list()]
assert uid1 != uid2
示例5: test_read_only_and_prefetch
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_read_only_and_prefetch():
a = MemoryStorage()
b = MemoryStorage()
b.read_only = True
status = {}
item1 = Item(u"UID:1\nhaha")
item2 = Item(u"UID:2\nhoho")
a.upload(item1)
a.upload(item2)
sync(a, b, status, force_delete=True)
sync(a, b, status, force_delete=True)
assert list(a.list()) == list(b.list()) == []
示例6: test_repair_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_repair_uids():
s = MemoryStorage()
s.upload(Item(u'BEGIN:VCARD\nEND:VCARD'))
repair_storage(s)
uid, = [s.get(href)[0].uid for href, etag in s.list()]
s.upload(Item(u'BEGIN:VCARD\nUID:{}\nEND:VCARD'.format(uid)))
uid1, uid2 = [s.get(href)[0].uid for href, etag in s.list()]
assert uid1 == uid2
repair_storage(s)
uid1, uid2 = [s.get(href)[0].uid for href, etag in s.list()]
assert uid1 != uid2
示例7: test_repair_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_repair_uids(uid):
s = MemoryStorage()
s.items = {
'one': (
'asdf',
Item(u'BEGIN:VCARD\nFN:Hans\nUID:{}\nEND:VCARD'.format(uid))
),
'two': (
'asdf',
Item(u'BEGIN:VCARD\nFN:Peppi\nUID:{}\nEND:VCARD'.format(uid))
)
}
uid1, uid2 = [s.get(href)[0].uid for href, etag in s.list()]
assert uid1 == uid2
repair_storage(s, repair_unsafe_uid=False)
uid1, uid2 = [s.get(href)[0].uid for href, etag in s.list()]
assert uid1 != uid2
示例8: test_moved_href
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
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"][1]["href"] == "haha"
示例9: test_repair_unsafe_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_repair_unsafe_uids(uid):
assert not href_safe(uid)
s = MemoryStorage()
href, etag = s.upload(Item(u'BEGIN:VCARD\nUID:{}\nEND:VCARD'.format(uid)))
assert s.get(href)[0].uid == uid
repair_storage(s)
new_href = list(s.list())[0][0]
assert href_safe(new_href)
newuid = s.get(new_href)[0].uid
assert href_safe(newuid)
示例10: test_repair_unsafe_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_repair_unsafe_uids(uid):
s = MemoryStorage()
item = Item(u'BEGIN:VCARD\nUID:123\nEND:VCARD').with_uid(uid)
href, etag = s.upload(item)
assert s.get(href)[0].uid == uid
assert not href_safe(uid)
repair_storage(s, repair_unsafe_uid=True)
new_href = list(s.list())[0][0]
assert href_safe(new_href)
newuid = s.get(new_href)[0].uid
assert href_safe(newuid)
示例11: test_repair_unsafe_uids
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_repair_unsafe_uids(uid):
s = MemoryStorage()
item = Item(u'BEGIN:VCARD\nUID:{}\nEND:VCARD'.format(uid))
print(repr(item.raw))
href, etag = s.upload(item)
assert s.get(href)[0].uid == uid
assert not href_safe(uid)
repair_storage(s, repair_unsafe_uid=True)
new_href = list(s.list())[0][0]
assert href_safe(new_href)
newuid = s.get(new_href)[0].uid
assert href_safe(newuid)
示例12: test_bogus_etag_change
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_bogus_etag_change():
'''Assert that sync algorithm is resilient against etag changes if content
didn\'t change.
In this particular case we test a scenario where both etags have been
updated, but only one side actually changed its item content.
'''
a = MemoryStorage()
b = MemoryStorage()
status = {}
href_a, etag_a = a.upload(Item(u'UID:ASDASD'))
sync(a, b, status)
assert len(status) == len(list(a.list())) == len(list(b.list())) == 1
(href_b, etag_b), = b.list()
a.update(href_a, Item(u'UID:ASDASD'), etag_a)
b.update(href_b, Item(u'UID:ASDASD\nACTUALCHANGE:YES'), etag_b)
b.delete = b.update = b.upload = blow_up
sync(a, b, status)
assert len(status) == 1
assert items(a) == items(b) == {u'UID:ASDASD\nACTUALCHANGE:YES'}
示例13: test_updated_and_deleted
# 需要导入模块: from vdirsyncer.storage.memory import MemoryStorage [as 别名]
# 或者: from vdirsyncer.storage.memory.MemoryStorage import list [as 别名]
def test_updated_and_deleted():
a = MemoryStorage()
b = MemoryStorage()
href_a, etag_a = a.upload(Item(u'UID:1'))
status = {}
sync(a, b, status, force_delete=True)
(href_b, etag_b), = b.list()
b.delete(href_b, etag_b)
updated = Item(u'UID:1\nupdated')
a.update(href_a, updated, etag_a)
sync(a, b, status, force_delete=True)
assert items(a) == items(b) == {updated.raw}