本文整理汇总了Python中task.models.Task.fromdict方法的典型用法代码示例。如果您正苦于以下问题:Python Task.fromdict方法的具体用法?Python Task.fromdict怎么用?Python Task.fromdict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task.models.Task
的用法示例。
在下文中一共展示了Task.fromdict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_task_fromdict_dependencies_dont_exist_yet
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import fromdict [as 别名]
def test_task_fromdict_dependencies_dont_exist_yet(self):
user = self.create_user()
task1_info = {'description': 'foobar',
'uuid': '1234abc',
'entry': '1234',
'project': 'test',
'user': user,
'status': 'pending',
}
task2_info = {'description': 'baz',
'uuid': 'aaaaaa',
'entry': '1237',
'depends': '1234abc',
'user': user,
'status': 'pending',
'annotation_123456': 'some note'
}
task2 = Task.fromdict(task2_info)
task1 = Task.fromdict(task1_info)
task2_info.pop('user')
task1_info.pop('user')
self.assertEqual(task1.todict(), task1_info)
self.assertEqual(task2.todict(), task2_info)
示例2: post_taskdb
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import fromdict [as 别名]
def post_taskdb(request, filename):
if filename not in TASK_FNAMES:
return HttpResponseForbidden('Forbidden!')
user = request.user
data = request.raw_post_data
if filename in ['pending.data', 'completed.data']:
parsed = [decode_task(line) for line in data.splitlines()]
if filename == 'pending.data':
tasks = Task.objects.filter(status='pending', user=user)
elif filename == 'completed.data':
tasks = Task.objects.filter(status__in=['completed', 'deleted'])
tasks.delete()
for task in parsed:
task.update({'user': user})
Task.fromdict(task)
elif filename == 'undo.data':
Undo.objects.all().delete()
parsed = parse_undo(data)
for undo_dict in parsed:
undo_dict.update({'user': user})
Undo.fromdict(undo_dict)
else:
return HttpResponseNotFound()
return HttpResponse()
示例3: test_task_fromdict_dependencies
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import fromdict [as 别名]
def test_task_fromdict_dependencies(self):
user = self.create_user()
task1 = Task(user=user, description='test')
task1.save(track=False)
task2 = Task(user=user, description='test2')
task2.save(track=False)
data = {'description': 'foobar', 'uuid': 'sssssssss',
'status': 'pending',
'entry': '12345',
'user': user,
'annotation_1324076995': u'this is an annotation',
'depends': u','.join([t.uuid for t in (task1, task2)]),
'priority': '',
}
task = Task.fromdict(data)
# ensure the data is in the db, not just the task
# object from above
task = Task.objects.get(description='foobar')
self.assertEqual(list(Undo.objects.all()), [])
data.pop('user')
data.pop('priority')
self.assertEqual(data, task.todict())
示例4: test_task_fromdict_track
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import fromdict [as 别名]
def test_task_fromdict_track(self):
user = self.create_user()
data = {'description': 'foobar', 'uuid': 'sssssssss',
'status': 'pending',
'entry': '12345',
'user': user,
'annotation_1324076995': u'this is an annotation',
'priority': 'H',
}
task = Task.fromdict(data, track=True)
# ensure the data is in the db, not just the task
# object from above
task = Task.objects.all()[0]
# see reasoning in the add_tasks_POST test
self.assertEqual(Undo.objects.count(), 2)
# this is a brand new task, the firts undo shouldn't
# have an 'old' field.
self.assertEqual(Undo.objects.all()[0].old, None)
data.pop('user')
self.assertEqual(data, task.todict())
undo2 = Undo.objects.all()[1]
self.assertNotEqual(undo2.old, undo2.new)
示例5: test_task_fromdict_optional_end
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import fromdict [as 别名]
def test_task_fromdict_optional_end(self):
user = self.create_user()
data = {'description': 'foobar', 'uuid': 'sssssssss',
'status': 'completed',
'entry': '12345',
'end': '45678',
'user': user,
'annotation_1324076995': 'this is an annotation',
}
task = Task.fromdict(data)
self.assertEqual(list(Undo.objects.all()), [])
data.pop('user')
self.assertEqual(data, task.todict())
示例6: test_task_fromdict
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import fromdict [as 别名]
def test_task_fromdict(self):
user = self.create_user()
data = {'description': 'foobar', 'uuid': 'sssssssss',
'status': 'pending',
'entry': '12345',
'user': user,
'annotation_1324076995': u'this is an annotation',
'priority': 'H',
}
task = Task.fromdict(data)
# ensure the data is in the db, not just the task
# object from above
task = Task.objects.all()[0]
self.assertEqual(list(Undo.objects.all()), [])
data.pop('user')
self.assertEqual(data, task.todict())