本文整理汇总了Python中avocado.models.DataContext.name方法的典型用法代码示例。如果您正苦于以下问题:Python DataContext.name方法的具体用法?Python DataContext.name怎么用?Python DataContext.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avocado.models.DataContext
的用法示例。
在下文中一共展示了DataContext.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_change
# 需要导入模块: from avocado.models import DataContext [as 别名]
# 或者: from avocado.models.DataContext import name [as 别名]
def test_change(self):
c = DataContext()
c.save()
revisions = Revision.objects.get_for_object(c)
self.assertEqual(revisions.count(), 1)
latest_revision = Revision.objects.latest_for_object(c)
self.assertFalse('old_value' in latest_revision.changes)
self.assertEqual(latest_revision.changes, {
'json': {'new_value': {}},
'name': {'new_value': None},
'description': {'new_value': None}
})
c.name = "New Name"
c.save()
revisions = Revision.objects.get_for_object(c)
self.assertEqual(revisions.count(), 2)
latest_revision = Revision.objects.latest_for_object(c)
self.assertEqual(latest_revision.changes, {
'name': {'old_value': None, 'new_value': 'New Name'}
})
示例2: test_cull_for_object
# 需要导入模块: from avocado.models import DataContext [as 别名]
# 或者: from avocado.models.DataContext import name [as 别名]
def test_cull_for_object(self):
c = DataContext(name="Test")
c.save()
Revision.objects.create_revision(c, fields=["name"])
for i in xrange(1, 100):
c.name = "Test{0}".format(i)
c.save()
Revision.objects.create_revision(c, fields=["name"])
self.assertEqual(Revision.objects.get_for_object(c).count(), 100)
# Cull down to the maximum size defined in the settings
Revision.objects.cull_for_object(c)
self.assertEqual(Revision.objects.get_for_object(c).count(), settings.HISTORY_MAX_SIZE)
# Cull down to an arbitrary size
Revision.objects.cull_for_object(c, max_size=20)
self.assertEqual(Revision.objects.get_for_object(c).count(), 20)
示例3: test_change
# 需要导入模块: from avocado.models import DataContext [as 别名]
# 或者: from avocado.models.DataContext import name [as 别名]
def test_change(self):
c = DataContext()
c.save()
revisions = Revision.objects.get_for_object(c)
self.assertEqual(revisions.count(), 1)
latest_revision = Revision.objects.latest_for_object(c)
self.assertFalse("old_value" in latest_revision.changes)
self.assertEqual(
latest_revision.changes,
{"json": {"new_value": {}}, "name": {"new_value": None}, "description": {"new_value": None}},
)
c.name = "New Name"
c.save()
revisions = Revision.objects.get_for_object(c)
self.assertEqual(revisions.count(), 2)
latest_revision = Revision.objects.latest_for_object(c)
self.assertEqual(latest_revision.changes, {"name": {"old_value": None, "new_value": "New Name"}})