• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.TestResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.TestResult的典型用法代码示例。如果您正苦于以下问题:Python TestResult类的具体用法?Python TestResult怎么用?Python TestResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TestResult类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_merge

    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:,项目名称:,代码行数:30,代码来源:


示例2: post

    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        log_id = int(self.request.get('id', 0))

        log = ReportLog.get_by_id(log_id)
        if not log or not log.commit:
            self.response.out.write("Not processed")
            return

        branch = log.branch()
        platform = log.platform()
        build = Build.get_or_insert_from_log(log)

        for test_name, result in log.results().iteritems():
            test = Test.update_or_insert(test_name, branch, platform)
            TestResult.get_or_insert_from_parsed_json(test_name, build, result)
            schedule_runs_update(test.id, branch.id, platform.id)

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
开发者ID:,项目名称:,代码行数:27,代码来源:


示例3: _create_results

 def _create_results(self, branch, platform, builder, test_name, values, timestamps=None):
     results = []
     for i, value in enumerate(values):
         build = Build(branch=branch, platform=platform, builder=builder,
             buildNumber=i, revision=100 + i, timestamp=timestamps[i] if timestamps else datetime.now())
         build.put()
         result = TestResult(name=test_name, build=build, value=value)
         result.put()
         results.append(result)
     return results
开发者ID:,项目名称:,代码行数:10,代码来源:


示例4: test_replace_to_change_test_name_overrides_conflicting_result

    def test_replace_to_change_test_name_overrides_conflicting_result(self):
        branch, platform, builder = _create_some_builder()
        build = _create_build(branch, platform, builder)
        self.assertThereIsNoInstanceOf(TestResult)
        result = TestResult.get_or_insert_from_parsed_json('some-test', build, 20)
        self.assertOnlyInstance(result)

        conflicting_result = TestResult.get_or_insert_from_parsed_json('other-test', build, 10)

        new_result = result.replace_to_change_test_name('other-test')
        self.assertNotEqual(result, new_result)
        self.assertOnlyInstance(new_result)

        self.assertEqual(new_result.name, 'other-test')
        self.assertEqual(TestResult.get(conflicting_result.key()).value, 20)
开发者ID:,项目名称:,代码行数:15,代码来源:


示例5: post

    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        log_id = int(self.request.get('id', 0))

        log = ReportLog.get_by_id(log_id)
        if not log or not log.commit:
            self.response.out.write("Not processed")
            return

        branch = log.branch()
        platform = log.platform()
        build = Build.get_or_insert_from_log(log)

        for test_name, result_value in log.results().iteritems():
            unit = result_value.get('unit') if isinstance(result_value, dict) else None
            test = Test.update_or_insert(test_name, branch, platform, unit)
            result = TestResult.get_or_insert_from_parsed_json(test_name, build, result_value)
            if not result:
                continue
            runs = Runs.get_by_objects(branch, platform, test)
            regenerate_runs = True
            if runs:
                runs.update_incrementally(build, result)
                regenerate_runs = False
            schedule_runs_update(test.id, branch.id, platform.id, regenerate_runs)

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
开发者ID:rniwa,项目名称:webkit-perf,代码行数:35,代码来源:report_process_handler.py


示例6: get

    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:,项目名称:,代码行数:57,代码来源:


示例7: _generate_runs

    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:,项目名称:,代码行数:12,代码来源:


示例8: test_get_or_insert_value

 def test_get_or_insert_value(self):
     branch, platform, builder = _create_some_builder()
     build = _create_build(branch, platform, builder)
     self.assertThereIsNoInstanceOf(TestResult)
     result = TestResult.get_or_insert_from_parsed_json('some-test', build, 50)
     self.assertOnlyInstance(result)
     self.assertEqual(result.name, 'some-test')
     self.assertEqual(result.build.key(), build.key())
     self.assertEqual(result.value, 50.0)
     self.assertEqual(result.valueMedian, None)
     self.assertEqual(result.valueStdev, None)
     self.assertEqual(result.valueMin, None)
     self.assertEqual(result.valueMax, None)
开发者ID:,项目名称:,代码行数:13,代码来源:


示例9: test_get_or_insert_stat_value

 def test_get_or_insert_stat_value(self):
     branch, platform, builder = _create_some_builder()
     build = _create_build(branch, platform, builder)
     self.assertThereIsNoInstanceOf(TestResult)
     result = TestResult.get_or_insert_from_parsed_json('some-test', build,
         {"avg": 40, "median": "40.1", "stdev": 3.25, "min": 30.5, "max": 45})
     self.assertOnlyInstance(result)
     self.assertEqual(result.name, 'some-test')
     self.assertEqual(result.build.key(), build.key())
     self.assertEqual(result.value, 40.0)
     self.assertEqual(result.valueMedian, 40.1)
     self.assertEqual(result.valueStdev, 3.25)
     self.assertEqual(result.valueMin, 30.5)
     self.assertEqual(result.valueMax, 45)
开发者ID:,项目名称:,代码行数:14,代码来源:


示例10: post

    def post(self):
        """
        Create a new test result
        :return: status of the request
        :raise HTTPError
        """

        # check for request payload
        if self.json_args is None:
            raise HTTPError(HTTP_BAD_REQUEST)

        # check for missing parameters in the request payload
        if self.json_args.get("project_name") is None:
            raise HTTPError(HTTP_BAD_REQUEST)
        if self.json_args.get("case_name") is None:
            raise HTTPError(HTTP_BAD_REQUEST)
        # check for pod_name instead of id,
        # keeping id for current implementations
        if self.json_args.get("pod_name") is None:
            raise HTTPError(HTTP_BAD_REQUEST)

        # TODO : replace checks with jsonschema
        # check for project
        mongo_dict = yield self.db.test_projects.find_one({"name": self.json_args.get("project_name")})
        if mongo_dict is None:
            raise HTTPError(HTTP_NOT_FOUND, "Could not find project [{}] ".format(self.json_args.get("project_name")))

        # check for case
        mongo_dict = yield self.db.test_cases.find_one({"name": self.json_args.get("case_name")})
        if mongo_dict is None:
            raise HTTPError(HTTP_NOT_FOUND, "Could not find case [{}] ".format(self.json_args.get("case_name")))

        # check for pod
        mongo_dict = yield self.db.pod.find_one({"name": self.json_args.get("pod_name")})
        if mongo_dict is None:
            raise HTTPError(HTTP_NOT_FOUND, "Could not find POD [{}] ".format(self.json_args.get("pod_name")))

        # convert payload to object
        test_result = TestResult.test_result_from_dict(self.json_args)
        test_result.creation_date = datetime.now()

        future = self.db.test_results.insert(test_result.format(), check_keys=False)
        result = yield future
        test_result._id = result

        self.finish_request(test_result.format_http())
开发者ID:radez,项目名称:opnfv-releng,代码行数:46,代码来源:handlers.py


示例11: test_replace_to_change_test_name

    def test_replace_to_change_test_name(self):
        branch, platform, builder = _create_some_builder()
        build = _create_build(branch, platform, builder)
        self.assertThereIsNoInstanceOf(TestResult)
        result = TestResult.get_or_insert_from_parsed_json('some-test', build, 50)
        self.assertOnlyInstance(result)
        self.assertEqual(result.name, 'some-test')

        new_result = result.replace_to_change_test_name('other-test')
        self.assertNotEqual(result, new_result)
        self.assertOnlyInstance(new_result)

        self.assertEqual(new_result.name, 'other-test')
        self.assertEqual(new_result.build.key(), result.build.key())
        self.assertEqual(new_result.value, result.value)
        self.assertEqual(new_result.valueMedian, None)
        self.assertEqual(new_result.valueStdev, None)
        self.assertEqual(new_result.valueMin, None)
        self.assertEqual(new_result.valueMax, None)
开发者ID:,项目名称:,代码行数:19,代码来源:


示例12: process_request

    def process_request(self, request):
        #noinspection PyBroadException
        if not AB_TEST_ACTIVE:
            return None
        try:
            sessionTests = request.session.get(AB_TEST_SESSION_NAME, {})
            if sessionTests is None: sessionTests = {}
            newSessionTests = {}
            requestTests = ABTestRequest()
            for activeTest in Test.objects.filter(active=True):
                if activeTest.pk in sessionTests and TestResult.objects.filter(pk=sessionTests[activeTest.pk]).exists():
                    activeTestResult = TestResult.objects.get(pk=sessionTests[activeTest.pk])
                else:
                    activeTestResult = TestResult.chooseExperiment(request, activeTest)
                newSessionTests[activeTest.pk] = activeTestResult.pk
                requestTests[activeTest] = activeTestResult
            request.session[AB_TEST_SESSION_NAME] = newSessionTests
            setattr(request, AB_TEST_REQUEST_NAME, requestTests)
        except Exception as ex:
            getLogger(AB_TEST_LOGGER_MIDDLEWARE).error("error processing request: %s", ex)
            if not AB_TEST_FAIL_SILENT_MIDDLEWARE:
                raise

        return None
开发者ID:camillo,项目名称:django-abTest,代码行数:24,代码来源:middleware.py


示例13: report_start

def report_start(request, mac):
    host, _ = Host.objects.get_or_create(_mac=mac)
    new_result = TestResult(host=host)
    new_result.save()
    return HttpResponse(host)
开发者ID:asin0622,项目名称:mypxe,代码行数:5,代码来源:views.py


示例14: get

    def get(self, result_id=None):
        """
        Retrieve result(s) for a test project on a specific POD.
        Available filters for this request are :
         - project : project name
         - case : case name
         - pod : pod name
         - version : platform version (Arno-R1, ...)
         - installer (fuel, ...)
         - build_tag : Jenkins build tag name
         - period : x (x last days)


        :param result_id: Get a result by ID
        :raise HTTPError

        GET /results/project=functest&case=vPing&version=Arno-R1 \
        &pod=pod_name&period=15
        => get results with optional filters
        """

        project_arg = self.get_query_argument("project", None)
        case_arg = self.get_query_argument("case", None)
        pod_arg = self.get_query_argument("pod", None)
        version_arg = self.get_query_argument("version", None)
        installer_arg = self.get_query_argument("installer", None)
        build_tag_arg = self.get_query_argument("build_tag", None)
        period_arg = self.get_query_argument("period", None)

        # prepare request
        get_request = dict()
        if result_id is None:
            if project_arg is not None:
                get_request["project_name"] = project_arg

            if case_arg is not None:
                get_request["case_name"] = case_arg

            if pod_arg is not None:
                get_request["pod_name"] = pod_arg

            if version_arg is not None:
                get_request["version"] = version_arg

            if installer_arg is not None:
                get_request["installer"] = installer_arg

            if build_tag_arg is not None:
                get_request["build_tag"] = build_tag_arg

            if period_arg is not None:
                try:
                    period_arg = int(period_arg)
                except:
                    raise HTTPError(HTTP_BAD_REQUEST)

                if period_arg > 0:
                    period = datetime.now() - timedelta(days=period_arg)
                    obj = {"$gte": str(period)}
                    get_request["creation_date"] = obj
        else:
            get_request["_id"] = result_id

        print get_request
        res = []
        # fetching results
        cursor = self.db.test_results.find(get_request)
        while (yield cursor.fetch_next):
            test_result = TestResult.test_result_from_dict(cursor.next_object())
            res.append(test_result.format_http())

        # building meta object
        meta = dict()
        meta["total"] = len(res)

        # final response object
        answer = dict()
        answer["test_results"] = res
        answer["meta"] = meta
        self.finish_request(answer)
开发者ID:radez,项目名称:opnfv-releng,代码行数:80,代码来源:handlers.py


示例15: test_get_or_insert_stat_value_with_values

 def test_get_or_insert_stat_value_with_values(self):
     branch, platform, builder = _create_some_builder()
     build = _create_build(branch, platform, builder)
     result = TestResult.get_or_insert_from_parsed_json('some-test', build,
         {"avg": 40, "median": "40.1", "stdev": 3.25, "min": 30.5, "max": 45, "values": [1.0, 2.0, 3.0]})
     self.assertEqual(result.values, [1.0, 2.0, 3.0])
开发者ID:,项目名称:,代码行数:6,代码来源:


示例16: test_run_from_build_and_result

    def test_run_from_build_and_result(self):
        branch = Branch.create_if_possible('some-branch', 'Some Branch')
        platform = Platform.create_if_possible('some-platform', 'Some Platform')
        builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        test_name = ' some-test'

        def create_build(build_number, revision):
            timestamp = datetime.now().replace(microsecond=0)
            build = Build(branch=branch, platform=platform, builder=builder, buildNumber=build_number,
                revision=revision, timestamp=timestamp)
            build.put()
            return build

        build = create_build(1, 101)
        result = TestResult(name=test_name, value=123.0, build=build)
        result.put()
        self._assert_entry(Runs._entry_from_build_and_result(build, result), build, result, 123.0)

        build = create_build(2, 102)
        result = TestResult(name=test_name, value=456.0, valueMedian=789.0, build=build)
        result.put()
        self._assert_entry(Runs._entry_from_build_and_result(build, result), build, result, 456.0)

        result.valueStdev = 7.0
        result.put()
        self._assert_entry(Runs._entry_from_build_and_result(build, result), build, result, 456.0)

        result.valueStdev = None
        result.valueMin = 123.0
        result.valueMax = 789.0
        result.put()
        self._assert_entry(Runs._entry_from_build_and_result(build, result), build, result, 456.0)

        result.valueStdev = 8.0
        result.valueMin = 123.0
        result.valueMax = 789.0
        result.put()
        self._assert_entry(Runs._entry_from_build_and_result(build, result), build, result, 456.0,
            statistics={'stdev': 8.0, 'min': 123.0, 'max': 789.0})

        result.valueMedian = 345.0  # Median is never used by the frontend.
        result.valueStdev = 8.0
        result.valueMin = 123.0
        result.valueMax = 789.0
        result.put()
        self._assert_entry(Runs._entry_from_build_and_result(build, result), build, result, 456.0,
            statistics={'stdev': 8.0, 'min': 123.0, 'max': 789.0})
开发者ID:,项目名称:,代码行数:47,代码来源:



注:本文中的models.TestResult类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Ticket类代码示例发布时间:2022-05-27
下一篇:
Python models.Test类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap