當前位置: 首頁>>代碼示例>>Python>>正文


Python TestResult.all方法代碼示例

本文整理匯總了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)
開發者ID:,項目名稱:,代碼行數:32,代碼來源:

示例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)
開發者ID:,項目名稱:,代碼行數:59,代碼來源:

示例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')
開發者ID:,項目名稱:,代碼行數:58,代碼來源:

示例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
開發者ID:,項目名稱:,代碼行數:14,代碼來源:


注:本文中的models.TestResult.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。