本文整理匯總了Python中tasks.models.Tasks.find_one方法的典型用法代碼示例。如果您正苦於以下問題:Python Tasks.find_one方法的具體用法?Python Tasks.find_one怎麽用?Python Tasks.find_one使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tasks.models.Tasks
的用法示例。
在下文中一共展示了Tasks.find_one方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_task
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import find_one [as 別名]
def _create_task(self):
"""Create task"""
task_id = Tasks.save({
'project': 'test',
'service': {
'name': 'travis_ci',
'job_id': 15,
}
})
return Tasks.find_one(task_id)
示例2: test_success
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import find_one [as 別名]
def test_success(self):
"""Test success"""
task_id = Tasks.save({
'project': 'test',
'service': {
'name': 'token',
'token': self.project.token,
}
})
data = Tasks.find_one(task_id)
task_id.should.be.equal(token_service(data))
示例3: get_last_task
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import find_one [as 別名]
def get_last_task(self):
"""Get last task"""
task = Tasks.find_one({
'project': self.name,
}, sort=[('created', DESCENDING)], fields={
name: True for name in (
'service', 'project', 'commit', 'plot',
'created', 'status', 'success_percent',
)
})
if task:
return task
else:
raise TaskDoesNotExists()
示例4: test_fail_with_wrong_project
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import find_one [as 別名]
def test_fail_with_wrong_project(self):
"""Test fail with wrong project"""
task_id = Tasks.save({
'project': 'test',
'service': {
'name': 'token',
'token': ProjectFactory().token,
}
})
data = Tasks.find_one(task_id)
with LogCapture() as log_capture:
token_service(data).should.be.none
list(log_capture.actual())[0].should.contain('ERROR')
Tasks.find({}).count().should.be.equal(0)
示例5: get_task
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import find_one [as 別名]
def get_task(self):
"""Get task"""
filter_spec = {
'project': self.cleaned_data['project'].name,
}
if self.cleaned_data.get('commit'):
filter_spec['commit.hash'] = self.cleaned_data['commit']
if self.cleaned_data.get('branch'):
filter_spec['commit.branch'] = self.cleaned_data['branch']
task = Tasks.find_one(
filter_spec, sort=[('created', DESCENDING)], fields={
'status': True,
},
)
if task:
return task
else:
raise TaskDoesNotExists(filter_spec)
示例6: update_quality_game
# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import find_one [as 別名]
def update_quality_game(self, task):
"""Update quality game"""
previous = Tasks.find_one({
'commit.branch': task['commit']['branch'],
'created': {'$lt': task['created']},
})
if not previous:
return
game = self._get_or_create_quality_game()
game['total'] = self._update_quality_object(
game['total'], task,
task.get('success_percent', 0) >=
previous.get('success_percent', 0),
)
for violation in task['violations']:
is_better = violation.get('success_percent', 0) >=\
self._get_violation_success_percent(task, violation['name'])
game['violations'][violation['name']] =\
self._update_quality_object(
game['violations'].get(violation['name'], {}), task,
is_better,
)
QualityGame.save(game)