Ejemplo n.º 1
0
def overall(request, template_name='report/list.html'):
    """Overall of products report"""
    SUB_MODULE_NAME = 'overall'

    products = {
        item['pk']: item['name'] for item in
        Product.objects.values('pk', 'name')
    }
    plans_count = stats.subtotal_plans(by='product')
    runs_count = stats.subtotal_test_runs(by='plan__product')
    cases_count = stats.subtotal_cases(by='plan__product')

    def generate_product_stats():
        for product_id, product_name in products.items():
            yield (
                product_id,
                product_name,
                plans_count[product_id],
                runs_count[product_id],
                cases_count[product_id],
            )

    context_data = {
        'module': MODULE_NAME,
        'sub_module': SUB_MODULE_NAME,
        'products': generate_product_stats(),
    }
    return render(request, template_name, context=context_data)
Ejemplo n.º 2
0
def overall(request):
    """Overall of products report"""
    products = {
        item['pk']: item['name'] for item in
        Product.objects.values('pk', 'name')
    }
    plans_count = stats.subtotal_plans(by='product')
    runs_count = stats.subtotal_test_runs(by='plan__product')
    cases_count = stats.subtotal_cases(by='plan__product')

    def generate_product_stats():
        for product_id, product_name in products.items():
            yield (
                product_id,
                product_name,
                plans_count.get(product_id, 0),
                runs_count.get(product_id, 0),
                cases_count.get(product_id, 0),
            )

    context_data = {
        'module': MODULE_NAME,
        'sub_module': 'overall',
        'products': generate_product_stats(),
    }
    return render(request, 'report/list.html', context=context_data)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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