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


Python DataContext.name方法代码示例

本文整理汇总了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'}
        })
开发者ID:hassanNS,项目名称:avocado,代码行数:27,代码来源:tests.py

示例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)
开发者ID:chop-dbhi,项目名称:avocado,代码行数:22,代码来源:tests.py

示例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"}})
开发者ID:chop-dbhi,项目名称:avocado,代码行数:24,代码来源:tests.py


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