本文整理汇总了Python中nailgun.task.helpers.TaskHelper.get_task_cache方法的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper.get_task_cache方法的具体用法?Python TaskHelper.get_task_cache怎么用?Python TaskHelper.get_task_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.task.helpers.TaskHelper
的用法示例。
在下文中一共展示了TaskHelper.get_task_cache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_task_cache
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import get_task_cache [as 别名]
def test_get_task_cache(self):
expected = {"key": "value"}
task = Task()
task.cache = expected
self.db.add(task)
self.db.flush()
actual = TaskHelper.get_task_cache(task)
self.assertDictEqual(expected, actual)
task_from_db = objects.Task.get_by_uuid(task.uuid)
self.db.delete(task_from_db)
self.db.flush()
expected = {}
actual = TaskHelper.get_task_cache(task)
self.assertDictEqual(expected, actual)
示例2: test_get_task_cache
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import get_task_cache [as 别名]
def test_get_task_cache(self):
expected = {"key": "value"}
task = Task()
task.cache = expected
self.db.add(task)
self.db.flush()
actual = TaskHelper.get_task_cache(task)
self.assertDictEqual(expected, actual)
# NOTE: We need to expire 'cache' attribute because otherwise
# the 'task.cache' won't throw 'ObjectDeletedError' and
# will be unable to test 'get_task_cache'.
self.db.expire(task, ['cache'])
task_from_db = objects.Task.get_by_uuid(task.uuid)
self.db.delete(task_from_db)
self.db.flush()
expected = {}
actual = TaskHelper.get_task_cache(task)
self.assertDictEqual(expected, actual)