本文整理汇总了Python中models.TestResult.all方法的典型用法代码示例。如果您正苦于以下问题:Python TestResult.all方法的具体用法?Python TestResult.all怎么用?Python TestResult.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.TestResult
的用法示例。
在下文中一共展示了TestResult.all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_merge
# 需要导入模块: from models import TestResult [as 别名]
# 或者: from models.TestResult import all [as 别名]
def test_merge(self):
branch, platform, builder = _create_some_builder()
some_build = _create_build(branch, platform, builder)
some_result = TestResult.get_or_insert_from_parsed_json('some-test', some_build, 50)
some_test = Test.update_or_insert('some-test', branch, platform)
other_build = _create_build(branch, platform, builder, 'other-build')
other_result = TestResult.get_or_insert_from_parsed_json('other-test', other_build, 30)
other_test = Test.update_or_insert('other-test', branch, platform)
self.assertOnlyInstances([some_result, other_result])
self.assertNotEqual(some_result.key(), other_result.key())
self.assertOnlyInstances([some_test, other_test])
self.assertRaises(AssertionError, some_test.merge, (some_test))
self.assertOnlyInstances([some_test, other_test])
some_test.merge(other_test)
results_for_some_test = TestResult.all()
results_for_some_test.filter('name =', 'some-test')
results_for_some_test = results_for_some_test.fetch(5)
self.assertEqual(len(results_for_some_test), 2)
self.assertEqual(results_for_some_test[0].name, 'some-test')
self.assertEqual(results_for_some_test[1].name, 'some-test')
if results_for_some_test[0].value == 50:
self.assertEqual(results_for_some_test[1].value, 30)
else:
self.assertEqual(results_for_some_test[1].value, 50)
示例2: get
# 需要导入模块: from models import TestResult [as 别名]
# 或者: from models.TestResult import all [as 别名]
def get(self):
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
try:
testId = int(self.request.get('id', 0))
branchId = int(self.request.get('branchid', 0))
platformId = int(self.request.get('platformid', 0))
except TypeError:
# FIXME: Output an error here
testId = 0
branchId = 0
platformId = 0
# FIXME: Just fetch builds specified by "days"
# days = self.request.get('days', 365)
cacheKey = Test.cacheKey(testId, branchId, platformId)
cache = memcache.get(cacheKey)
if cache:
self.response.out.write(cache)
return
builds = Build.all()
builds.filter('branch =', modelFromNumericId(branchId, Branch))
builds.filter('platform =', modelFromNumericId(platformId, Platform))
test = modelFromNumericId(testId, Test)
testName = test.name if test else None
test_runs = []
averages = {}
values = []
timestamps = []
for build in builds:
results = TestResult.all()
results.filter('name =', testName)
results.filter('build =', build)
for result in results:
builderId = build.builder.key().id()
posixTimestamp = mktime(build.timestamp.timetuple())
test_runs.append([result.key().id(),
[build.key().id(), build.buildNumber, build.revision],
posixTimestamp, result.value, 0, [], builderId])
# FIXME: Calculate the average; in practice, we wouldn't have more than one value for a given revision
averages[build.revision] = result.value
values.append(result.value)
timestamps.append(posixTimestamp)
result = json.dumps({
'test_runs': test_runs,
'averages': averages,
'min': min(values) if values else None,
'max': max(values) if values else None,
'date_range': [min(timestamps), max(timestamps)] if timestamps else None,
'stat': 'ok'})
self.response.out.write(result)
memcache.add(cacheKey, result)
示例3: post
# 需要导入模块: from models import TestResult [as 别名]
# 或者: from models.TestResult import all [as 别名]
def post(self):
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
try:
test_id = int(self.request.get('id', 0))
branch_id = int(self.request.get('branchid', 0))
platform_id = int(self.request.get('platformid', 0))
except TypeError:
# FIXME: Output an error here
test_id = 0
branch_id = 0
platform_id = 0
# FIXME: Just fetch builds specified by "days"
# days = self.request.get('days', 365)
builds = Build.all()
builds.filter('branch =', modelFromNumericId(branch_id, Branch))
builds.filter('platform =', modelFromNumericId(platform_id, Platform))
test = modelFromNumericId(test_id, Test)
test_name = test.name if test else None
test_runs = []
averages = {}
values = []
timestamps = []
for build in builds:
results = TestResult.all()
results.filter('name =', test_name)
results.filter('build =', build)
for result in results:
builderId = build.builder.key().id()
posixTimestamp = mktime(build.timestamp.timetuple())
statistics = None
if result.valueStdev != None and result.valueMin != None and result.valueMax != None:
statistics = {'stdev': result.valueStdev, 'min': result.valueMin, 'max': result.valueMax}
test_runs.append([result.key().id(),
[build.key().id(), build.buildNumber, build.revision],
posixTimestamp, result.value, 0, # runNumber
[], # annotations
builderId, statistics])
# FIXME: Calculate the average; in practice, we wouldn't have more than one value for a given revision
averages[build.revision] = result.value
values.append(result.value)
timestamps.append(posixTimestamp)
result = json.dumps({
'test_runs': test_runs,
'averages': averages,
'min': min(values) if values else None,
'max': max(values) if values else None,
'date_range': [min(timestamps), max(timestamps)] if timestamps else None,
'stat': 'ok'})
cache_runs(test_id, branch_id, platform_id, result)
self.response.out.write('OK')
示例4: _generate_runs
# 需要导入模块: from models import TestResult [as 别名]
# 或者: from models.TestResult import all [as 别名]
def _generate_runs(branch, platform, test_name):
builds = Build.all()
builds.filter('branch =', branch)
builds.filter('platform =', platform)
for build in builds:
results = TestResult.all()
results.filter('name =', test_name)
results.filter('build =', build)
for result in results:
yield build, result
raise StopIteration