本文整理汇总了Python中casexml.apps.phone.models.SimplifiedSyncLog.prune_case方法的典型用法代码示例。如果您正苦于以下问题:Python SimplifiedSyncLog.prune_case方法的具体用法?Python SimplifiedSyncLog.prune_case怎么用?Python SimplifiedSyncLog.prune_case使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类casexml.apps.phone.models.SimplifiedSyncLog
的用法示例。
在下文中一共展示了SimplifiedSyncLog.prune_case方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prune_self_indexing
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_self_indexing(self):
[id] = ['recursive']
tree = IndexTree(indices={
id: convert_list_to_dict([id]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set([id]))
sync_log.prune_case(id)
self.assertFalse(id in sync_log.case_ids_on_phone)
self.assertFalse(id in sync_log.dependent_case_ids_on_phone)
示例2: test_prune_partial_children
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_partial_children(self):
[parent_id, child_id_1, child_id_2] = all_ids = ['parent', 'child1', 'child2']
tree = IndexTree(indices={
child_id_1: convert_list_to_dict([parent_id]),
child_id_2: convert_list_to_dict([parent_id]),
})
sync_log = SimplifiedSyncLog(
index_tree=tree,
case_ids_on_phone=set(all_ids),
dependent_case_ids_on_phone=set([parent_id, child_id_2])
)
# this used to fail with an AssertionError
sync_log.prune_case(parent_id)
示例3: test_prune_multiple_children
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_multiple_children(self):
[grandparent_id, parent_id, child_id_1, child_id_2] = all_ids = ['rickard', 'ned', 'bran', 'arya']
tree = IndexTree(indices={
child_id_1: convert_list_to_dict([parent_id]),
child_id_2: convert_list_to_dict([parent_id]),
parent_id: convert_list_to_dict([grandparent_id]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# first prune the parent and grandparent
sync_log.prune_case(grandparent_id)
sync_log.prune_case(parent_id)
self.assertTrue(grandparent_id in sync_log.case_ids_on_phone)
self.assertTrue(grandparent_id in sync_log.dependent_case_ids_on_phone)
self.assertTrue(parent_id in sync_log.case_ids_on_phone)
self.assertTrue(parent_id in sync_log.dependent_case_ids_on_phone)
# just pruning one child should preserve the parent index
sync_log.prune_case(child_id_1)
self.assertTrue(grandparent_id in sync_log.case_ids_on_phone)
self.assertTrue(grandparent_id in sync_log.dependent_case_ids_on_phone)
self.assertTrue(parent_id in sync_log.case_ids_on_phone)
self.assertTrue(parent_id in sync_log.dependent_case_ids_on_phone)
self.assertFalse(child_id_1 in sync_log.case_ids_on_phone)
# pruning the other one should wipe it
sync_log.prune_case(child_id_2)
for id in all_ids:
self.assertFalse(id in sync_log.case_ids_on_phone)
self.assertFalse(id in sync_log.dependent_case_ids_on_phone)
示例4: test_prune_parent_then_child
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_parent_then_child(self):
[parent_id, child_id] = all_ids = ['parent', 'child']
tree = IndexTree(indices={
child_id: convert_list_to_dict([parent_id]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# this has no effect
sync_log.prune_case(parent_id)
self.assertTrue(child_id in sync_log.case_ids_on_phone)
self.assertTrue(parent_id in sync_log.case_ids_on_phone)
self.assertFalse(child_id in sync_log.dependent_case_ids_on_phone)
self.assertTrue(parent_id in sync_log.dependent_case_ids_on_phone)
# this should prune it entirely
sync_log.prune_case(child_id)
self.assertFalse(child_id in sync_log.case_ids_on_phone)
self.assertFalse(parent_id in sync_log.case_ids_on_phone)
示例5: test_prune_circular_loops
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_circular_loops(self):
[peer_id_1, peer_id_2] = all_ids = ['jaime', 'cersei']
tree = IndexTree(indices={
peer_id_1: convert_list_to_dict([peer_id_2]),
peer_id_2: convert_list_to_dict([peer_id_1]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# pruning one peer should keep everything around
sync_log.prune_case(peer_id_1)
for id in all_ids:
self.assertTrue(id in sync_log.case_ids_on_phone)
# pruning the second peer should remove everything
sync_log.prune_case(peer_id_2)
for id in all_ids:
self.assertFalse(id in sync_log.case_ids_on_phone)
示例6: test_prune_very_circular_loops
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_very_circular_loops(self):
[peer_id_1, peer_id_2, peer_id_3] = all_ids = ['drogon', 'rhaegal', 'viserion']
tree = IndexTree(indices={
peer_id_1: convert_list_to_dict([peer_id_2]),
peer_id_2: convert_list_to_dict([peer_id_3]),
peer_id_3: convert_list_to_dict([peer_id_1]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# pruning the first two, should still keep everything around
sync_log.prune_case(peer_id_1)
sync_log.prune_case(peer_id_2)
for id in all_ids:
self.assertTrue(id in sync_log.case_ids_on_phone)
sync_log.prune_case(peer_id_3)
for id in all_ids:
self.assertFalse(id in sync_log.case_ids_on_phone)
示例7: test_prune_tiered_top_down
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_tiered_top_down(self):
[grandparent_id, parent_id, child_id] = all_ids = ['grandparent', 'parent', 'child']
tree = IndexTree(indices={
child_id: convert_list_to_dict([parent_id]),
parent_id: convert_list_to_dict([grandparent_id]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# this has no effect other than to move the grandparent to dependent
sync_log.prune_case(grandparent_id)
for id in all_ids:
self.assertTrue(id in sync_log.case_ids_on_phone)
self.assertTrue(grandparent_id in sync_log.dependent_case_ids_on_phone)
self.assertFalse(parent_id in sync_log.dependent_case_ids_on_phone)
self.assertFalse(child_id in sync_log.dependent_case_ids_on_phone)
# likewise, this should have no effect other than to move the parent to dependent
sync_log.prune_case(parent_id)
for id in all_ids:
self.assertTrue(id in sync_log.case_ids_on_phone)
self.assertTrue(grandparent_id in sync_log.dependent_case_ids_on_phone)
self.assertTrue(parent_id in sync_log.dependent_case_ids_on_phone)
self.assertFalse(child_id in sync_log.dependent_case_ids_on_phone)
# this should now prune everything
sync_log.prune_case(child_id)
for id in all_ids:
self.assertFalse(id in sync_log.case_ids_on_phone)
self.assertFalse(id in sync_log.dependent_case_ids_on_phone)
示例8: test_prune_tiered_bottom_up
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_tiered_bottom_up(self):
[grandparent_id, parent_id, child_id] = all_ids = ['grandparent', 'parent', 'child']
tree = IndexTree(indices={
child_id: convert_list_to_dict([parent_id]),
parent_id: convert_list_to_dict([grandparent_id]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# just pruning the child should prune just the child
sync_log.prune_case(child_id)
self.assertTrue(grandparent_id in sync_log.case_ids_on_phone)
self.assertTrue(parent_id in sync_log.case_ids_on_phone)
self.assertFalse(child_id in sync_log.case_ids_on_phone)
# same for the parent
sync_log.prune_case(parent_id)
self.assertTrue(grandparent_id in sync_log.case_ids_on_phone)
self.assertFalse(parent_id in sync_log.case_ids_on_phone)
# same for the grandparentparent
sync_log.prune_case(grandparent_id)
self.assertFalse(grandparent_id in sync_log.case_ids_on_phone)
示例9: test_prune_multiple_parents
# 需要导入模块: from casexml.apps.phone.models import SimplifiedSyncLog [as 别名]
# 或者: from casexml.apps.phone.models.SimplifiedSyncLog import prune_case [as 别名]
def test_prune_multiple_parents(self):
[grandparent_id, mother_id, father_id, child_id] = all_ids = ['heart-tree', 'catelyn', 'ned', 'arya']
tree = IndexTree(indices={
child_id: convert_list_to_dict([mother_id, father_id]),
mother_id: convert_list_to_dict([grandparent_id]),
father_id: convert_list_to_dict([grandparent_id]),
})
sync_log = SimplifiedSyncLog(index_tree=tree, case_ids_on_phone=set(all_ids))
# first prune everything but the child
sync_log.prune_case(grandparent_id)
sync_log.prune_case(mother_id)
sync_log.prune_case(father_id)
# everything should still be relevant because of the child
for id in all_ids:
self.assertTrue(id in sync_log.case_ids_on_phone)
# pruning the child should wipe everything else
sync_log.prune_case(child_id)
for id in all_ids:
self.assertFalse(id in sync_log.case_ids_on_phone)
self.assertFalse(id in sync_log.dependent_case_ids_on_phone)