Ejemplo n.º 1
0
        def walk_status_matrix_rows():
            """For rendering template, walk through status matrix row by row"""
            prev_build = None
            builds = sorted(status_matrix.items(), key=lambda item: item[0])
            for build_id, tested_by_ids in builds:
                build_rowspan = len(tested_by_ids)
                tested_by_ids = sorted(tested_by_ids.items(),
                                       key=lambda item: item[0] or 0)
                for tested_by_id, status_subtotal in tested_by_ids:
                    if build_id not in runs_subtotal:
                        runs_count = 0
                    elif tested_by_id not in runs_subtotal[build_id]:
                        runs_count = 0
                    else:
                        runs_count = runs_subtotal[build_id][tested_by_id]

                    build = Build(pk=build_id,
                                  name=build_names.get(build_id, ''))
                    if build == prev_build:
                        _build = (build, None)
                    else:
                        _build = (build, build_rowspan)
                        prev_build = build

                    tested_by_username = tested_by_names.get(
                        tested_by_id, None)
                    tested_by = None
                    if tested_by_username is not None:
                        tested_by = User(pk=tested_by_id,
                                         username=tested_by_username)

                    yield _build, tested_by, runs_count, status_subtotal
Ejemplo n.º 2
0
    def status_matrix(self, form):
        query = self._filter_query(
            form,
            TestCaseRun.objects.values(
                'run__plan', 'run__plan__name', 'build', 'build__name', 'run',
                'run__summary',
                'case_run_status__name').annotate(total_count=Count('pk')))
        status_matrix = GroupByResult()

        for row in query:
            plan_id = row['run__plan']
            plan_name = row['run__plan__name']
            build_id = row['build']
            build_name = row['build__name']
            run_id = row['run']
            run_summary = row['run__summary']
            status_name = row['case_run_status__name']
            total_count = row['total_count']

            plan = TestPlan(pk=plan_id, name=plan_name)
            builds = status_matrix.setdefault(plan, GroupByResult())

            build = Build(pk=build_id, name=build_name)
            runs = builds.setdefault(build, GroupByResult())

            run = TestRun(pk=run_id, summary=run_summary)
            status_subtotal = runs.setdefault(run, GroupByResult())
            status_subtotal[status_name] = total_count

        return status_matrix
Ejemplo n.º 3
0
 def populate(self, product_id):
     # We can dynamically set choices for a form field:
     # Seen at: http://my.opera.com/jacob7908/blog/2009/06/19/
     #          django-choicefield-queryset (Chinese)
     # Is this documented elsewhere?
     query = {'product_id': product_id}
     self.fields['build'].queryset = Build.list_active(query)
Ejemplo n.º 4
0
        def builds(self):
            from tcms.management.models import Build

            try:
                _is_active = bool(
                    strtobool(self.request.GET.get('is_active', 'False')))
            except (ValueError, TypeError):
                _is_active = False

            query = {'product_id': self.product_id, 'is_active': _is_active}
            return Build.list(query)
Ejemplo n.º 5
0
def filter(query={}):
    """
    .. function:: XML-RPC Build.filter(query)

        Search and return builds matching query.

        :param query: Field lookups for :class:`tcms.management.models.Build`
        :type query: dict
        :return: List of serialized :class:`tcms.management.models.Build` objects
        :rtype: list(dict)
    """
    return Build.to_xmlrpc(query)
Ejemplo n.º 6
0
 def populate(self, product_id=None):
     # We can dynamically set choices for a form field:
     # Seen at: http://my.opera.com/jacob7908/blog/2009/06/19/
     #          django-choicefield-queryset (Chinese)
     # Is this documented elsewhere?
     if product_id:
         self.fields['product_version'].queryset = Version.objects.filter(
             product__pk=product_id)
         self.fields['build'].queryset = Build.objects.filter(
             product__pk=product_id)
     else:
         self.fields['product_version'].queryset = Version.objects.all()
         self.fields['build'].queryset = Build.list_active()
Ejemplo n.º 7
0
def filter(query=None):  # pylint: disable=redefined-builtin
    """
    .. function:: XML-RPC Build.filter(query)

        Search and return builds matching query.

        :param query: Field lookups for :class:`tcms.management.models.Build`
        :type query: dict
        :return: List of serialized :class:`tcms.management.models.Build` objects
        :rtype: list(dict)
    """

    if query is None:
        query = {}
    return Build.to_xmlrpc(query)
Ejemplo n.º 8
0
Archivo: data.py Proyecto: sugus86/Kiwi
    def status_matrix(self, form):
        status_matrix = GroupByResult()
        query = self._filter_query(
            form,
            TestCaseRun.objects.values(
                'build', 'build__name', 'run__plan__tag', 'run__plan',
                'run__plan__name', 'run', 'run__summary',
                'case_run_status__name').annotate(total_count=Count('pk')))

        for row in query:
            builds = status_matrix.setdefault(row['run__plan__tag'],
                                              GroupByResult())
            plans = builds.setdefault(
                Build(pk=row['build'], name=row['build__name']),
                GroupByResult())
            runs = plans.setdefault(
                TestPlan(pk=row['run__plan'], name=row['run__plan__name']),
                GroupByResult())
            status_subtotal = runs.setdefault(
                TestRun(pk=row['run'], summary=row['run__summary']),
                GroupByResult())
            status_subtotal[row['case_run_status__name']] = row['total_count']

        return status_matrix
Ejemplo n.º 9
0
 def populate(self, product_id):
     query = {'product_id': product_id}
     self.fields['build'].queryset = Build.list_active(query)