Esempio n. 1
0
def search_runs(queries):
    runs    = SmartDjangoQuery(queries, TestRun.__name__)
    runs    = runs.evaluate()
    if runs is None:
        return None
    #runs    = annotate_runs_with_case_run_count_by_status(runs)
    return runs
Esempio n. 2
0
    def test_with_invalid_target(self):

        with self.assertRaises(ValueError, msg='Invalid target'):
            _sum_orm_queries(SmartDjangoQuery({}, TestPlan.__name__),
                             SmartDjangoQuery({}, TestCase.__name__),
                             SmartDjangoQuery({}, TestRun.__name__),
                             'INVALID_TARGET')
Esempio n. 3
0
def search_runs(queries):
    runs = SmartDjangoQuery(queries, TestRun.__name__)
    runs = runs.evaluate()
    if runs is None:
        return None
    #runs    = annotate_runs_with_case_run_count_by_status(runs)
    return runs
Esempio n. 4
0
File: views.py Progetto: xbln/Kiwi
def caseruns(request, templ='report/caseruns.html'):
    '''View that search caseruns.'''
    queries = request.GET
    r_form = RunForm(queries)
    r_form.populate(queries)
    context = {}
    if r_form.is_valid():
        runs = SmartDjangoQuery(r_form.cleaned_data, TestRun.__name__)
        runs = runs.evaluate()
        caseruns = get_caseruns_of_runs(runs, queries)
        context['test_case_runs'] = caseruns
        context['runs'] = runs
    return render(request, templ, context)
Esempio n. 5
0
def caseruns(request, templ='report/caseruns.html'):
    """View that search caseruns."""
    queries = request.GET
    r_form = RunForm(queries)
    r_form.populate(queries)
    context = {}
    if r_form.is_valid():
        runs = SmartDjangoQuery(r_form.cleaned_data, TestRun.__name__)
        runs = runs.evaluate()
        caseruns = get_caseruns_of_runs(runs, queries)
        context['test_case_runs'] = caseruns
        context['runs'] = runs
    response = direct_to_template(request, templ, context)
    return response
Esempio n. 6
0
def _query(plan_query, run_query, case_query, target):
    plans = SmartDjangoQuery(plan_query, TestPlan.__name__)
    runs = SmartDjangoQuery(run_query, TestRun.__name__)
    cases = SmartDjangoQuery(case_query, TestCase.__name__)

    return _sum_orm_queries(plans, cases, runs, target)
Esempio n. 7
0
def sum_orm_queries(plans: SmartDjangoQuery, cases: SmartDjangoQuery,
                    runs: SmartDjangoQuery, target: str) -> QuerySet:
    """Search target objects together with selected relatives

    :return: a QuerySet object representing queried target objects.
    :rtype: QuerySet
    """
    plans = plans.evaluate()
    cases = cases.evaluate()
    runs = runs.evaluate()

    if target == 'run':
        if plans is None and cases is None:
            if runs is None:
                runs = TestRun.objects.none()
        if runs is None:
            runs = TestRun.objects.all()
        if cases is not None:
            runs = runs.filter(case_run__case__in=cases).distinct()
        if plans is not None:
            runs = runs.filter(plan__in=plans).distinct()
        runs = runs.extra(select={'cases_count': RawSQL.total_num_caseruns})
        return (runs.select_related('manager', 'default_tester',
                                    'build__product', 'product_version').only(
                                        'pk', 'summary', 'stop_date',
                                        'manager__username',
                                        'default_tester__username',
                                        'build__product__name',
                                        'product_version__value'))

    if target == 'plan':
        if cases is None and runs is None:
            if plans is None:
                plans = TestPlan.objects.none()
        if plans is None:
            plans = TestPlan.objects.all()
        if cases is not None:
            plans = plans.filter(case__in=cases).distinct()
        if runs is not None:
            plans = plans.filter(run__in=runs).distinct()
        return (TestPlan.apply_subtotal(
            plans, cases_count=True, runs_count=True).select_related(
                'author', 'owner', 'type',
                'product').only('pk', 'name', 'is_active', 'author__username',
                                'owner__username', 'product__name',
                                'type__name'))

    if target == 'case':
        if plans is None and runs is None:
            if cases is None:
                cases = TestCase.objects.none()
        if cases is None:
            cases = TestCase.objects.all()
        if runs is not None:
            cases = cases.filter(case_run__run__in=runs).distinct()
        if plans is not None:
            cases = cases.filter(plan__in=plans).distinct()
        return (cases.select_related(
            'author', 'default_tester', 'case_status', 'category',
            'priority').only('pk', 'summary', 'create_date', 'is_automated',
                             'is_automated_proposed', 'author__username',
                             'default_tester__username', 'case_status__name',
                             'category__name', 'priority__value'))