Exemple #1
0
    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:
            tag_id = row['run__plan__tag']
            build_id = row['build']
            build_name = row['build__name']
            plan_id = row['run__plan']
            plan_name = row['run__plan__name']
            run_id = row['run']
            run_summary = row['run__summary']
            status_name = row['case_run_status__name']
            total_count = row['total_count']

            builds = status_matrix.setdefault(tag_id, GroupByResult())
            plans = builds.setdefault(TestBuild(pk=build_id, name=build_name),
                                      GroupByResult())
            runs = plans.setdefault(TestPlan(pk=plan_id, name=plan_name),
                                    GroupByResult())
            status_subtotal = runs.setdefault(
                TestRun(pk=run_id, summary=run_summary), GroupByResult())
            status_subtotal[status_name] = total_count

        return status_matrix
Exemple #2
0
        def walk_status_matrix_rows():
            '''For rendering template, walk through status matrix row by row'''
            prev_build = None
            builds = sorted(status_matrix.iteritems(),
                            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.iteritems(),
                                       key=lambda item: item[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 = TestBuild(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
Exemple #3
0
        def builds(self):
            from tcms.management.models import TestBuild

            query = {
                'product_id': self.product_id,
                'is_active': self.request.GET.get('is_active')
            }
            return TestBuild.list(query)
Exemple #4
0
        def builds(self):
            from tcms.management.models import TestBuild

            query = {
                'product_id': self.product_id,
                'is_active': self.request.GET.get('is_active')
            }
            return TestBuild.list(query)
Exemple #5
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['product_version'].queryset = Version.objects.filter(
         product__id=product_id)
     self.fields['build'].queryset = TestBuild.list_active(query)
Exemple #6
0
        def builds(self):
            from tcms.management.models import TestBuild

            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 TestBuild.list(query)
Exemple #7
0
    def _get_builds(self):
        '''Get builds from valid form

        @param form: the form containing valid data
        @type form: L{CustomSearchForm}
        @return: queried test builds
        @rtype: L{QuerySet}
        '''
        sql, params = self._prepare_sql(sqls.custom_builds)
        rows = SQLExecution(sql, params).rows
        return [TestBuild(pk=row['build_id'], name=row['name'])
                for row in rows]
Exemple #8
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.TestBuild`
        :type query: dict
        :return: List of serialized :class:`tcms.management.models.TestBuild` objects
        :rtype: list(dict)
    """
    return TestBuild.to_xmlrpc(query)
Exemple #9
0
    def _get_builds(self):
        """Get builds from valid form

        :param form: the form containing valid data
        :type form: :class:`CustomSearchForm`
        :return: queried test builds
        :rtype: QuerySet
        """
        sql, params = self._prepare_sql(sqls.custom_builds)
        rows = SQLExecution(sql, params).rows
        return [
            TestBuild(pk=row['build_id'], name=row['name']) for row in rows
        ]
Exemple #10
0
    def status_matrix(self, form):
        sql, params = self._prepare_sql(form,
                                        sqls.by_plan_tags_detail_status_matrix)
        rows = SQLExecution(sql, params, with_field_name=False).rows

        status_matrix = GroupByResult()

        for row in rows:
            (tag_id, build_id, build_name, plan_id, plan_name, run_id,
             run_summary, status_name, total_count) = row

            builds = status_matrix.setdefault(tag_id, GroupByResult())
            plans = builds.setdefault(TestBuild(pk=build_id, name=build_name),
                                      GroupByResult())
            runs = plans.setdefault(TestPlan(pk=plan_id, name=plan_name),
                                    GroupByResult())
            status_subtotal = runs.setdefault(
                TestRun(pk=run_id, summary=run_summary), GroupByResult())
            status_subtotal[status_name] = total_count

        return status_matrix
Exemple #11
0
def get_builds(request, product, is_active=True):
    """Get the list of builds associated with this product.

    :param product: product ID or name.
    :type product: int or str
    :param bool is_active: if ``True``, only return active builds. Otherwise,
        inactive builds will be returned.
    :return: a list of mappings of :class:`TestBuild`.
    :rtype: list

    Example::

        # Get with product id including all builds
        >>> Product.get_builds(1)
        # Get with product name excluding all inactive builds
        >>> Product.get_builds('product name', 0)
    """
    from tcms.management.models import TestBuild

    p = pre_check_product(values=product)
    query = {'product': p, 'is_active': parse_bool_value(is_active)}
    return TestBuild.to_xmlrpc(query)
Exemple #12
0
def get_builds(request, product, is_active=True):
    """
    Description: Get the list of builds associated with this product.

    Params:      $product  -  Integer/String
                              Integer: product_id of the product in the Database
                              String: Product name
                 $is_active - Boolean: True to only include builds where is_active is true.
                              Default: True
    Returns:     Array: Returns an array of Build objects.

    Example:
    # Get with product id including all builds
    >>> Product.get_builds(61)
    # Get with product name excluding all inactive builds
    >>> Product.get_builds('Red Hat Enterprise Linux 5', 0)
    """
    from tcms.management.models import TestBuild

    p = pre_check_product(values=product)
    query = {'product': p, 'is_active': parse_bool_value(is_active)}
    return TestBuild.to_xmlrpc(query)
Exemple #13
0
def get_builds(request, product, is_active=True):
    """
    Description: Get the list of builds associated with this product.

    Params:      $product  -  Integer/String
                              Integer: product_id of the product in the Database
                              String: Product name
                 $is_active - Boolean: True to only include builds where is_active is true.
                              Default: True
    Returns:     Array: Returns an array of Build objects.

    Example:
    # Get with product id including all builds
    >>> Product.get_builds(61)
    # Get with product name excluding all inactive builds
    >>> Product.get_builds('Red Hat Enterprise Linux 5', 0)
    """
    from tcms.management.models import TestBuild

    p = pre_check_product(values=product)
    query = {'product': p, 'is_active': parse_bool_value(is_active)}
    return TestBuild.to_xmlrpc(query)
Exemple #14
0
def get_builds(request, product, is_active=True):
    """Get the list of builds associated with this product.

    :param product: product ID or name.
    :type product: int or str
    :param bool is_active: if ``True``, only return active builds. Otherwise,
        inactive builds will be returned.
    :return: a list of mappings of :class:`TestBuild`.
    :rtype: list

    Example::

        # Get with product id including all builds
        >>> Product.get_builds(1)
        # Get with product name excluding all inactive builds
        >>> Product.get_builds('product name', 0)
    """
    from tcms.management.models import TestBuild

    p = pre_check_product(values=product)
    query = {'product': p, 'is_active': parse_bool_value(is_active)}
    return TestBuild.to_xmlrpc(query)