本文整理汇总了Python中couchexport.models.ExportSchema.get_all_checkpoints方法的典型用法代码示例。如果您正苦于以下问题:Python ExportSchema.get_all_checkpoints方法的具体用法?Python ExportSchema.get_all_checkpoints怎么用?Python ExportSchema.get_all_checkpoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchexport.models.ExportSchema
的用法示例。
在下文中一共展示了ExportSchema.get_all_checkpoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_all_checkpoints
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get_all_checkpoints [as 别名]
def test_get_all_checkpoints(self):
index = ["mydomain", "myxmlns"]
self.addCleanup(lambda: [cp.delete() for cp in ExportSchema.get_all_checkpoints(index)])
schema1 = ExportSchema(index=index, timestamp=datetime.utcnow())
schema1.save()
schema1_prime, = list(ExportSchema.get_all_checkpoints(index))
self.assert_docs_equal(schema1_prime, schema1)
schema2 = ExportSchema(index=index, timestamp=datetime.utcnow())
schema2.save()
schema1_prime, schema2_prime = list(ExportSchema.get_all_checkpoints(index))
self.assert_docs_equal(schema1_prime, schema1)
self.assert_docs_equal(schema2_prime, schema2)
示例2: rebuild_schemas
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get_all_checkpoints [as 别名]
def rebuild_schemas(index):
"""
Resets the schema for all checkpoints to the latest version based off the
current document structure. Returns the number of checkpoints updated.
"""
db = ExportSchema.get_db()
all_checkpoints = ExportSchema.get_all_checkpoints(index)
config = ExportConfiguration(db, index, disable_checkpoints=True)
latest = config.create_new_checkpoint()
for cp in all_checkpoints:
cp.schema = latest.schema
cp.save()
return len(all_checkpoints)
示例3: test_get_last
# 需要导入模块: from couchexport.models import ExportSchema [as 别名]
# 或者: from couchexport.models.ExportSchema import get_all_checkpoints [as 别名]
def test_get_last(self):
indices = ["a string", ["a", "list"]]
save_args = get_safe_write_kwargs()
for index in indices:
self.addCleanup(
lambda idx: [cp.delete() for cp in ExportSchema.get_all_checkpoints(idx)],
index
)
for index in indices:
self.assertEqual(None, ExportSchema.last(index))
dt = datetime.utcnow()
schema1 = ExportSchema(index=index, timestamp=dt)
schema1.save(**save_args)
self.assert_docs_equal(schema1, ExportSchema.last(index))
schema2 = ExportSchema(index=index, timestamp=dt + timedelta(seconds=1))
schema2.save(**save_args)
self.assert_docs_equal(schema2, ExportSchema.last(index))
schema3 = ExportSchema(index=index, timestamp=dt - timedelta(seconds=1))
schema3.save(**save_args)
# still schema2 (which has a later date than schema3)
self.assert_docs_equal(schema2, ExportSchema.last(index))