Пример #1
0
    def _report_data_context(self):
        data = {}
        form = self._get_search_form()

        if form.is_valid():
            summary_header_data = super(CustomDetailReport,
                                        self)._report_data_context()
            data.update(summary_header_data)

            build_ids = [build.pk for build in data['builds']]
            # TODO: remove this after upgrading MySQL-python to 1.2.5
            build_ids = workaround_single_value_for_in_clause(build_ids)

            status_matrix = self.walk_matrix_row_by_row(
                self._data.generate_status_matrix(build_ids))

            # TODO: remove this after upgrading MySQL-python to 1.2.5
            status_ids = workaround_single_value_for_in_clause(
                (TestCaseRunStatus.id_failed(), ))
            failed_case_runs = self.read_case_runs(build_ids, status_ids)
            # TODO: remove this after upgrading MySQL-python to 1.2.5
            status_ids = workaround_single_value_for_in_clause(
                (TestCaseRunStatus.id_blocked(), ))
            blocked_case_runs = self.read_case_runs(build_ids, status_ids)

            data.update({
                'status_matrix': status_matrix,
                'failed_case_runs': failed_case_runs,
                'blocked_case_runs': blocked_case_runs,
            })
        else:
            data['report_errors'] = form.errors

        data['form'] = form
        return data
Пример #2
0
    def _report_data_context(self):
        data = {}
        form = self._get_search_form()

        if form.is_valid():
            summary_header_data = super(CustomDetailReport,
                                        self)._report_data_context()
            data.update(summary_header_data)

            build_ids = [build.pk for build in data['builds']]
            # TODO: remove this after upgrading MySQL-python to 1.2.5
            build_ids = tuple(workaround_single_value_for_in_clause(build_ids))

            status_matrix = self.walk_matrix_row_by_row(
                self._data.generate_status_matrix(build_ids))

            # TODO: remove this after upgrading MySQL-python to 1.2.5
            status_ids = workaround_single_value_for_in_clause(
                (TestCaseRunStatus.name_to_id('FAILED'),))
            failed_case_runs = self.read_case_runs(build_ids, status_ids)
            # TODO: remove this after upgrading MySQL-python to 1.2.5
            status_ids = workaround_single_value_for_in_clause(
                (TestCaseRunStatus.name_to_id('BLOCKED'),))
            blocked_case_runs = self.read_case_runs(build_ids, status_ids)

            data.update({
                'status_matrix': status_matrix,
                'failed_case_runs': failed_case_runs,
                'blocked_case_runs': blocked_case_runs,
            })
        else:
            data['report_errors'] = form.errors

        data['form'] = form
        return data
Пример #3
0
    def _report_data_context(self):
        form = self._get_search_form()
        context = {'form': form}

        if not form.is_valid():
            context.update({'builds': ()})
            return context

        _data = self.data_class(form)
        self._data = _data

        builds = _data._get_builds()
        build_ids = [build.pk for build in builds]

        # TODO: remove this after upgrading MySQL-python to 1.2.5
        build_ids = workaround_single_value_for_in_clause(build_ids)

        if build_ids:
            # Summary header data
            runs_subtotal = _data.runs_subtotal()
            plans_subtotal = _data.plans_subtotal()
            case_runs_subtotal = _data.case_runs_subtotal()
            isautomated_subtotal = _data.cases_isautomated_subtotal()

            # Staus matrix used to render progress bar for each build
            case_runs_status_matrix = _data.status_matrix()

            # FIXME: this would raise KeyError once status names are modified
            # to other ones.
            passed_id = TestCaseRunStatus.name_to_id('PASSED')
            failed_id = TestCaseRunStatus.name_to_id('FAILED')

            for build in builds:
                bid = build.pk
                build.runs_count = runs_subtotal.get(bid, 0)
                build.plans_count = plans_subtotal.get(bid, 0)
                build.case_runs_count = case_runs_subtotal.get(bid, 0)

                status_subtotal = case_runs_status_matrix.get(bid, {})
                passed_count = status_subtotal.get(passed_id, 0)
                failed_count = status_subtotal.get(failed_id, 0)

                c = case_runs_subtotal.get(bid, 0)

                if c:
                    build.passed_case_runs_percent = passed_count * 100.0 / c
                    build.failed_case_runs_percent = failed_count * 100.0 / c
                else:
                    build.passed_case_runs_percent = .0
                    build.failed_case_runs_percent = .0

                build.passed_case_runs_count = passed_count
                build.failed_case_runs_count = failed_count
                build.case_runs_count = c

            context.update({
                # method invocation.
                'total_runs_count': runs_subtotal.total,
                'total_plans_count': plans_subtotal.total,
                'total_count': isautomated_subtotal.total,
                'manual_count': isautomated_subtotal.get(0, 0),
                'auto_count': isautomated_subtotal.get(1, 0),
                'both_count': isautomated_subtotal.get(2, 0),
            })

        context.update({'builds': builds})
        return context
Пример #4
0
def models_to_pks(models):
    return tuple(workaround_single_value_for_in_clause(
        [model.pk for model in models]))
Пример #5
0
def models_to_pks(models):
    return tuple(
        workaround_single_value_for_in_clause([model.pk for model in models]))
Пример #6
0
    'CustomDetailsReportData',
    'CustomReportData',
    'overview_view_get_case_run_status_count',
    'overview_view_get_running_runs_count',
    'ProductBuildReportData',
    'ProductComponentReportData',
    'ProductVersionReportData',
    'TestingReportByCasePriorityData',
    'TestingReportByCaseRunTesterData',
    'TestingReportByPlanBuildData',
    'TestingReportByPlanTagsData',
    'TestingReportByPlanTagsDetailData',
    'TestingReportCaseRunsData',
)

models_to_pks = lambda models: workaround_single_value_for_in_clause(
    [model.pk for model in models])
model_to_pk = lambda model: model.pk
do_nothing = lambda value: value


def overview_view_get_running_runs_count(product_id):
    return get_groupby_result(sqls.overview_running_runs_count,
                              (product_id,),
                              key_name='stop_status',
                              with_rollup=True)


def overview_view_get_case_run_status_count(product_id):
    return get_groupby_result(sqls.overview_case_run_status_count,
                              (product_id,),
                              key_name='name',
Пример #7
0
    def _report_data_context(self):
        form = self._get_search_form()
        context = {'form': form}

        if not form.is_valid():
            context.update({'builds': ()})
            return context

        _data = self.data_class(form)
        self._data = _data

        builds = _data._get_builds()
        build_ids = [build.pk for build in builds]

        # TODO: remove this after upgrading MySQL-python to 1.2.5
        build_ids = workaround_single_value_for_in_clause(build_ids)

        if build_ids:
            # Summary header data
            runs_subtotal = _data.runs_subtotal()
            plans_subtotal = _data.plans_subtotal()
            case_runs_subtotal = _data.case_runs_subtotal()
            isautomated_subtotal = _data.cases_isautomated_subtotal()

            # Staus matrix used to render progress bar for each build
            case_runs_status_matrix = _data.status_matrix()

            status_names_ids = TestCaseRunStatus.get_names_ids()
            # FIXME: this would raise KeyError once status names are modified
            # to other ones.
            passed_id = status_names_ids['PASSED']
            failed_id = status_names_ids['FAILED']

            for build in builds:
                bid = build.pk
                build.runs_count = runs_subtotal.get(bid, 0)
                build.plans_count = plans_subtotal.get(bid, 0)
                build.case_runs_count = case_runs_subtotal.get(bid, 0)

                status_subtotal = case_runs_status_matrix.get(bid, {})
                passed_count = status_subtotal.get(passed_id, 0)
                failed_count = status_subtotal.get(failed_id, 0)

                c = case_runs_subtotal.get(bid, 0)

                if c:
                    build.passed_case_runs_percent = passed_count * 100.0 / c
                    build.failed_case_runs_percent = failed_count * 100.0 / c
                else:
                    build.passed_case_runs_percent = .0
                    build.failed_case_runs_percent = .0

                build.passed_case_runs_count = passed_count
                build.failed_case_runs_count = failed_count
                build.case_runs_count = c

            context.update({
                # TODO: replace following three TOTAL key lookup with total
                # method invocation.
                'total_runs_count': runs_subtotal.get('TOTAL', 0),
                'total_plans_count': plans_subtotal.get('TOTAL', 0),
                'total_count': isautomated_subtotal.get('TOTAL', 0),
                'manual_count': isautomated_subtotal.get(0, 0),
                'auto_count': isautomated_subtotal.get(1, 0),
                'both_count': isautomated_subtotal.get(2, 0),
            })

        context.update({'builds': builds})
        return context