当前位置: 首页>>代码示例>>Python>>正文


Python SavedBasicExport.by_index方法代码示例

本文整理汇总了Python中couchexport.models.SavedBasicExport.by_index方法的典型用法代码示例。如果您正苦于以下问题:Python SavedBasicExport.by_index方法的具体用法?Python SavedBasicExport.by_index怎么用?Python SavedBasicExport.by_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在couchexport.models.SavedBasicExport的用法示例。


在下文中一共展示了SavedBasicExport.by_index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_by_index

# 需要导入模块: from couchexport.models import SavedBasicExport [as 别名]
# 或者: from couchexport.models.SavedBasicExport import by_index [as 别名]
 def test_get_by_index(self):
     index = ['some', 'index']
     saved_export = SavedBasicExport(configuration=_mk_config(index=index))
     saved_export.save()
     back = SavedBasicExport.by_index(index)
     self.assertEqual(1, len(back))
     self.assertEqual(saved_export._id, back[0]._id)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:9,代码来源:test_saved.py

示例2: test_get_saved_and_delete_copies_multiple

# 需要导入模块: from couchexport.models import SavedBasicExport [as 别名]
# 或者: from couchexport.models.SavedBasicExport import by_index [as 别名]
    def test_get_saved_and_delete_copies_multiple(self):
        index = ['multiple']
        # make three exports with the last one being the most recently updated
        timestamp = datetime.datetime.utcnow()
        for i in range(3):
            saved_export = SavedBasicExport(configuration=_mk_config(index=index),
                                            last_updated=timestamp + datetime.timedelta(days=i))
            saved_export.save()

        self.assertEqual(3, len(SavedBasicExport.by_index(index)))
        chosen_one = get_saved_export_and_delete_copies(index)
        # this relies on the variable being set last in the loop which is a bit unintuitive
        self.assertEqual(saved_export._id, chosen_one._id)
        saved_after_deletion = SavedBasicExport.by_index(index)
        self.assertEqual(1, len(saved_after_deletion))
        self.assertEqual(chosen_one._id, saved_after_deletion[0]._id)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:18,代码来源:test_saved.py

示例3: get_saved_export_and_delete_copies

# 需要导入模块: from couchexport.models import SavedBasicExport [as 别名]
# 或者: from couchexport.models.SavedBasicExport import by_index [as 别名]
def get_saved_export_and_delete_copies(index):
    matching = SavedBasicExport.by_index(index)
    if not matching:
        return None
    if len(matching) == 1:
        return matching[0]
    else:
        # delete all matches besides the last updated match
        matching = sorted(matching, key=lambda x: x.last_updated)
        for match in matching[:-1]:
            match.delete()
        return matching[-1]
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:14,代码来源:groupexports.py


注:本文中的couchexport.models.SavedBasicExport.by_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。