示例#1
0
文件: views.py 项目: artjoman/Nitrate
    def get_context_data(self, **kwargs):
        components = self.product.component.select_related('product')
        components = components.only('name', 'product__name')

        pid = self.product.pk

        subtotal_case_runs = stats.subtotal_case_runs(
            {'case__component__product': pid},
            by='case__component')

        failed_case_runs_count = stats.subtotal_case_runs(
            {
                'case__component__product': pid,
                'case_run_status__name': 'FAILED'
            },
            by='case__component')

        finished_case_runs_count = stats.subtotal_case_runs(
            {
                'case__component__product': pid,
                'case_run_status__name__in':
                    TestCaseRunStatus.complete_status_names
            },
            by='case__component')

        for component in components:
            cid = component.pk
            component.case_runs_count = subtotal_case_runs.get(cid, 0)
            component.failed_case_run_count = failed_case_runs_count.get(cid,
                                                                         0)

            n = finished_case_runs_count.get(cid, 0)
            m = subtotal_case_runs.get(cid, 0)
            if n and m:
                component.finished_case_run_percent = round(n * 100.0 / m, 1)
            else:
                component.finished_case_run_percent = 0

        # To show detail statistics upon case run status if user clicks a
        # component
        case_runs_status_subtotal = None
        selected_component = getattr(self, 'selected_component', None)
        if selected_component is not None:
            case_runs_status_subtotal = stats.subtotal_case_run_status(
                {'case_runs__case__component': selected_component.pk})

        data = super().get_context_data(**kwargs)
        data.update({
            'module': MODULE_NAME,
            'SUB_MODULE_NAME': self.submodule_name,
            'product': self.product,
            'components': components,
            'component': selected_component,
            'case_runs_status_subtotal': case_runs_status_subtotal,
        })

        return data
示例#2
0
文件: views.py 项目: tkdchen/Nitrate
    def get_context_data(self, **kwargs):
        components = self.product.component.select_related('product')
        components = components.only('name', 'product__name')

        pid = self.product.pk

        subtotal_case_runs = stats.subtotal_case_runs(
            {'case__component__product': pid},
            by='case__component')

        failed_case_runs_count = stats.subtotal_case_runs(
            {
                'case__component__product': pid,
                'case_run_status__name': 'FAILED'
            },
            by='case__component')

        finished_case_runs_count = stats.subtotal_case_runs(
            {
                'case__component__product': pid,
                'case_run_status__name__in':
                    TestCaseRunStatus.complete_status_names
            },
            by='case__component')

        for component in components:
            cid = component.pk
            component.case_runs_count = subtotal_case_runs.get(cid, 0)
            component.failed_case_run_count = failed_case_runs_count.get(cid,
                                                                         0)

            n = finished_case_runs_count.get(cid, 0)
            m = subtotal_case_runs.get(cid, 0)
            if n and m:
                component.finished_case_run_percent = round(n * 100.0 / m, 1)
            else:
                component.finished_case_run_percent = 0

        # To show detail statistics upon case run status if user clicks a
        # component
        case_runs_status_subtotal = None
        selected_component = getattr(self, 'selected_component', None)
        if selected_component is not None:
            case_runs_status_subtotal = stats.subtotal_case_run_status(
                {'case_runs__case__component': selected_component.pk})

        data = super(ProductComponentReport, self).get_context_data(**kwargs)
        data.update({
            'module': MODULE_NAME,
            'SUB_MODULE_NAME': self.submodule_name,
            'product': self.product,
            'components': components,
            'component': selected_component,
            'case_runs_status_subtotal': case_runs_status_subtotal,
        })

        return data
示例#3
0
def overview(request, product_id, template_name='report/overview.html'):
    """Product for a product"""
    try:
        product = Product.objects.only('name').get(pk=product_id)
    except Product.DoesNotExist as error:
        raise Http404(error)

    runs_count = overview_view_get_running_runs_count(product.pk)
    caserun_status_count = stats.subtotal_case_run_status(
        filter_={'case_runs__run__plan__product': product.pk})

    context_data = {
        'module': MODULE_NAME,
        'SUB_MODULE_NAME': 'overview',
        'product': product,
        'runs_count': runs_count,
        'case_run_count': caserun_status_count,
    }
    return render(request, template_name, context=context_data)
示例#4
0
文件: views.py 项目: tkdchen/Nitrate
def overview(request, product_id, template_name='report/overview.html'):
    """Product for a product"""
    try:
        product = Product.objects.only('name').get(pk=product_id)
    except Product.DoesNotExist as error:
        raise Http404(error)

    runs_count = overview_view_get_running_runs_count(product.pk)
    caserun_status_count = stats.subtotal_case_run_status(
        filter_={'case_runs__run__plan__product': product.pk}
    )

    context_data = {
        'module': MODULE_NAME,
        'SUB_MODULE_NAME': 'overview',
        'product': product,
        'runs_count': runs_count,
        'case_run_count': caserun_status_count,
    }
    return render(request, template_name, context=context_data)
示例#5
0
文件: views.py 项目: tkdchen/Nitrate
    def get_context_data(self, **kwargs):
        builds = self.product.build.only('product', 'name')

        pid = self.product.pk

        builds_total_runs = stats.subtotal_test_runs(
            filter_={'build__product': pid}, by='build')

        builds_finished_runs = stats.subtotal_test_runs(
            filter_={'build__product': pid, 'stop_date__isnull': False},
            by='build')

        builds_finished_caseruns = stats.subtotal_case_runs(
            filter_={
                'run__build__product': pid,
                'case_run_status__name__in':
                    TestCaseRunStatus.complete_status_names,
            },
            by='run__build')

        builds_caseruns = stats.subtotal_case_runs(
            filter_={'run__build__product': pid},
            by='run__build')

        builds_failed_caseruns = stats.subtotal_case_runs(
            filter_={
                'run__build__product': pid,
                'case_run_status__name': 'FAILED',
            },
            by='run__build')

        for build in builds:
            bid = build.pk
            build.total_runs = builds_total_runs.get(bid, 0)
            build.finished_runs = builds_finished_runs.get(bid, 0)
            build.failed_case_run_count = builds_failed_caseruns.get(bid, 0)

            n = builds_finished_caseruns.get(bid, 0)
            m = builds_caseruns.get(bid, 0)
            if n and m:
                build.finished_case_run_percent = round(n * 100.0 / m, 1)
            else:
                build.finished_case_run_percent = .0

        case_runs_status_subtotal = None
        selected_build = getattr(self, 'selected_build', None)
        if selected_build is not None:
            case_runs_status_subtotal = stats.subtotal_case_run_status(
                filter_={
                    'case_runs__run__build__product': pid,
                    'case_runs__run__build': selected_build.pk,
                })

        data = super(ProductBuildReport, self).get_context_data(**kwargs)
        data.update({
            'module': MODULE_NAME,
            'SUB_MODULE_NAME': 'build',
            'product': self.product,
            'builds': builds,
            'build': selected_build,
            'case_runs_status_subtotal': case_runs_status_subtotal,
        })

        return data
示例#6
0
文件: views.py 项目: tkdchen/Nitrate
    def get_context_data(self, **kwargs):
        versions = self.product.version.only('product', 'value')
        product_id = self.product.pk

        plans_subtotal = stats.subtotal_plans(
            filter_={'product': product_id}, by='product_version')

        running_runs_subtotal = stats.subtotal_test_runs(
            filter_={
                'plan__product': product_id,
                'stop_date__isnull': True,
            },
            by='plan__product_version')

        finished_runs_subtotal = stats.subtotal_test_runs(
            filter_={
                'plan__product': product_id,
                'stop_date__isnull': False,
            },
            by='plan__product_version')

        cases_subtotal = stats.subtotal_cases(
            filter_={'plan__product': product_id},
            by='plan__product_version')

        case_runs_subtotal = stats.subtotal_case_runs(
            filter_={'run__plan__product': product_id},
            by='run__plan__product_version'
        )

        finished_case_runs_subtotal = stats.subtotal_case_runs(
            filter_={
                'run__plan__product': product_id,
                'case_run_status__name__in':
                    TestCaseRunStatus.complete_status_names
            },
            by='run__plan__product_version')

        failed_case_runs_subtotal = stats.subtotal_case_runs(
            filter_={
                'run__plan__product': product_id,
                'case_run_status__name': 'FAILED',
            },
            by='run__plan__product_version')

        for version in versions:
            vid = version.pk
            version.plans_count = plans_subtotal.get(vid, 0)
            version.running_runs_count = running_runs_subtotal.get(vid, 0)
            version.finished_runs_count = finished_runs_subtotal.get(vid, 0)
            version.cases_count = cases_subtotal.get(vid, 0)
            version.failed_case_runs_count = failed_case_runs_subtotal.get(vid,
                                                                           0)

            m = finished_case_runs_subtotal.get(vid, 0)
            n = case_runs_subtotal.get(vid, 0)
            if m and n:
                version.case_run_percent = round(m * 100.0 / n, 1)
            else:
                version.case_run_percent = .0

        case_runs_status_subtotal = None
        selected_version = getattr(self, 'selected_version', None)
        if selected_version is not None:
            case_runs_status_subtotal = stats.subtotal_case_run_status(
                filter_={
                    'case_runs__run__plan__product': product_id,
                    'case_runs__run__plan__product_version': selected_version,
                })

        data = super(ProductVersionReport, self).get_context_data(**kwargs)
        data.update({
            'module': MODULE_NAME,
            'SUB_MODULE_NAME': 'version',
            'product': self.product,
            'versions': versions,
            'version': selected_version,
            'case_runs_status_subtotal': case_runs_status_subtotal,
        })

        return data
示例#7
0
文件: views.py 项目: artjoman/Nitrate
    def get_context_data(self, **kwargs):
        builds = self.product.build.only('product', 'name')

        pid = self.product.pk

        builds_total_runs = stats.subtotal_test_runs(
            filter_={'build__product': pid}, by='build')

        builds_finished_runs = stats.subtotal_test_runs(
            filter_={'build__product': pid, 'stop_date__isnull': False},
            by='build')

        builds_finished_caseruns = stats.subtotal_case_runs(
            filter_={
                'run__build__product': pid,
                'case_run_status__name__in':
                    TestCaseRunStatus.complete_status_names,
            },
            by='run__build')

        builds_caseruns = stats.subtotal_case_runs(
            filter_={'run__build__product': pid},
            by='run__build')

        builds_failed_caseruns = stats.subtotal_case_runs(
            filter_={
                'run__build__product': pid,
                'case_run_status__name': 'FAILED',
            },
            by='run__build')

        for build in builds:
            bid = build.pk
            build.total_runs = builds_total_runs.get(bid, 0)
            build.finished_runs = builds_finished_runs.get(bid, 0)
            build.failed_case_run_count = builds_failed_caseruns.get(bid, 0)

            n = builds_finished_caseruns.get(bid, 0)
            m = builds_caseruns.get(bid, 0)
            if n and m:
                build.finished_case_run_percent = round(n * 100.0 / m, 1)
            else:
                build.finished_case_run_percent = .0

        case_runs_status_subtotal = None
        selected_build = getattr(self, 'selected_build', None)
        if selected_build is not None:
            case_runs_status_subtotal = stats.subtotal_case_run_status(
                filter_={
                    'case_runs__run__build__product': pid,
                    'case_runs__run__build': selected_build.pk,
                })

        data = super().get_context_data(**kwargs)
        data.update({
            'module': MODULE_NAME,
            'SUB_MODULE_NAME': 'build',
            'product': self.product,
            'builds': builds,
            'build': selected_build,
            'case_runs_status_subtotal': case_runs_status_subtotal,
        })

        return data
示例#8
0
文件: views.py 项目: artjoman/Nitrate
    def get_context_data(self, **kwargs):
        versions = self.product.version.only('product', 'value')
        product_id = self.product.pk

        plans_subtotal = stats.subtotal_plans(
            filter_={'product': product_id}, by='product_version')

        running_runs_subtotal = stats.subtotal_test_runs(
            filter_={
                'plan__product': product_id,
                'stop_date__isnull': True,
            },
            by='plan__product_version')

        finished_runs_subtotal = stats.subtotal_test_runs(
            filter_={
                'plan__product': product_id,
                'stop_date__isnull': False,
            },
            by='plan__product_version')

        cases_subtotal = stats.subtotal_cases(
            filter_={'plan__product': product_id},
            by='plan__product_version')

        case_runs_subtotal = stats.subtotal_case_runs(
            filter_={'run__plan__product': product_id},
            by='run__plan__product_version'
        )

        finished_case_runs_subtotal = stats.subtotal_case_runs(
            filter_={
                'run__plan__product': product_id,
                'case_run_status__name__in':
                    TestCaseRunStatus.complete_status_names
            },
            by='run__plan__product_version')

        failed_case_runs_subtotal = stats.subtotal_case_runs(
            filter_={
                'run__plan__product': product_id,
                'case_run_status__name': 'FAILED',
            },
            by='run__plan__product_version')

        for version in versions:
            vid = version.pk
            version.plans_count = plans_subtotal.get(vid, 0)
            version.running_runs_count = running_runs_subtotal.get(vid, 0)
            version.finished_runs_count = finished_runs_subtotal.get(vid, 0)
            version.cases_count = cases_subtotal.get(vid, 0)
            version.failed_case_runs_count = failed_case_runs_subtotal.get(vid,
                                                                           0)

            m = finished_case_runs_subtotal.get(vid, 0)
            n = case_runs_subtotal.get(vid, 0)
            if m and n:
                version.case_run_percent = round(m * 100.0 / n, 1)
            else:
                version.case_run_percent = .0

        case_runs_status_subtotal = None
        selected_version = getattr(self, 'selected_version', None)
        if selected_version is not None:
            case_runs_status_subtotal = stats.subtotal_case_run_status(
                filter_={
                    'case_runs__run__plan__product': product_id,
                    'case_runs__run__plan__product_version': selected_version,
                })

        data = super().get_context_data(**kwargs)
        data.update({
            'module': MODULE_NAME,
            'SUB_MODULE_NAME': 'version',
            'product': self.product,
            'versions': versions,
            'version': selected_version,
            'case_runs_status_subtotal': case_runs_status_subtotal,
        })

        return data