def _report_data_context(self): data = {} form = self._get_search_form() if form.is_valid(): summary_header_data = super(CustomDetailReport, self)._report_data_context() data.update(summary_header_data) build_ids = [build['build'] for build in data['builds']] status_matrix = self.walk_matrix_row_by_row( self._data.generate_status_matrix(build_ids) ) status_ids = (TestCaseRunStatus.id_failed(),) failed_case_runs = self.read_case_runs(build_ids, status_ids) status_ids = (TestCaseRunStatus.id_blocked(),) blocked_case_runs = self.read_case_runs(build_ids, status_ids) data.update({ 'status_matrix': status_matrix, 'failed_case_runs': failed_case_runs, 'blocked_case_runs': blocked_case_runs, }) else: data['report_errors'] = form.errors data['form'] = form return data
def _report_data_context(self): data = {} form = self._get_search_form() if form.is_valid(): summary_header_data = super(CustomDetailReport, self)._report_data_context() data.update(summary_header_data) build_ids = [build.pk for build in data['builds']] # TODO: remove this after upgrading MySQL-python to 1.2.5 build_ids = workaround_single_value_for_in_clause(build_ids) status_matrix = self.walk_matrix_row_by_row( self._data.generate_status_matrix(build_ids)) # TODO: remove this after upgrading MySQL-python to 1.2.5 status_ids = workaround_single_value_for_in_clause( (TestCaseRunStatus.id_failed(), )) failed_case_runs = self.read_case_runs(build_ids, status_ids) # TODO: remove this after upgrading MySQL-python to 1.2.5 status_ids = workaround_single_value_for_in_clause( (TestCaseRunStatus.id_blocked(), )) blocked_case_runs = self.read_case_runs(build_ids, status_ids) data.update({ 'status_matrix': status_matrix, 'failed_case_runs': failed_case_runs, 'blocked_case_runs': blocked_case_runs, }) else: data['report_errors'] = form.errors data['form'] = form return data
def _report_data_context(self): data = {} form = self._get_search_form() if form.is_valid(): summary_header_data = super(CustomDetailReport, self)._report_data_context() data.update(summary_header_data) build_ids = [build.pk for build in data['builds']] # TODO: remove this after upgrading MySQL-python to 1.2.5 build_ids = workaround_single_value_for_in_clause(build_ids) status_matrix = self.walk_matrix_row_by_row( self._data.generate_status_matrix(build_ids)) # TODO: remove this after upgrading MySQL-python to 1.2.5 status_ids = workaround_single_value_for_in_clause( (TestCaseRunStatus.id_failed(),)) failed_case_runs = self.read_case_runs(build_ids, status_ids) # TODO: remove this after upgrading MySQL-python to 1.2.5 status_ids = workaround_single_value_for_in_clause( (TestCaseRunStatus.id_blocked(),)) blocked_case_runs = self.read_case_runs(build_ids, status_ids) data.update({ 'status_matrix': status_matrix, 'failed_case_runs': failed_case_runs, 'blocked_case_runs': blocked_case_runs, }) else: data['report_errors'] = form.errors data['form'] = form return data
def _report_data_context(self): data = {} form = self._get_search_form() if form.is_valid(): summary_header_data = super(CustomDetailReport, self)._report_data_context() data.update(summary_header_data) build_ids = [build['build'] for build in data['builds']] status_matrix = self.walk_matrix_row_by_row( self._data.generate_status_matrix(build_ids) ) status_ids = (TestCaseRunStatus.id_failed(),) failed_case_runs = self.read_case_runs(build_ids, status_ids) status_ids = (TestCaseRunStatus.id_blocked(),) blocked_case_runs = self.read_case_runs(build_ids, status_ids) data.update({ 'status_matrix': status_matrix, 'failed_case_runs': failed_case_runs, 'blocked_case_runs': blocked_case_runs, }) else: data['report_errors'] = form.errors data['form'] = form return data
def load_runs_of_one_plan(request, plan_id, template_name='plan/common/json_plan_runs.txt'): """A dedicated view to return a set of runs of a plan This view is used in a plan detail page, for the contained testrun tab. It replaces the original solution, with a paginated resultset in return, serves as a performance healing. Also, in order for user to locate the data, it accepts field lookup parameters collected from the filter panel in the UI. """ column_names = [ '', 'run_id', 'summary', 'manager__username', 'default_tester__username', 'start_date', 'build__name', 'stop_date', 'total_num_caseruns', 'failure_caseruns_percent', 'successful_caseruns_percent', ] test_plan = TestPlan.objects.get(plan_id=plan_id) form = PlanFilterRunForm(request.GET) if form.is_valid(): queryset = test_plan.run.filter(**form.cleaned_data) queryset = queryset.select_related('build', 'manager', 'default_tester').order_by('-pk') data_table_result = DataTableResult(request.GET, queryset, column_names) response_data = data_table_result.get_response_data() searched_runs = response_data['querySet'] # Get associated statistics data run_filters = dict(('run__{0}'.format(key), value) for key, value in form.cleaned_data.items()) query_set = TestCaseRun.objects.filter( case_run_status=TestCaseRunStatus.id_failed(), **run_filters).values('run', 'case_run_status').annotate( count=Count('pk')).order_by('run', 'case_run_status') failure_subtotal = magic_convert(query_set, key_name='run', value_name='count') query_set = TestCaseRun.objects.filter( case_run_status=TestCaseRunStatus.id_passed(), **run_filters).values('run', 'case_run_status').annotate( count=Count('pk')).order_by('run', 'case_run_status') success_subtotal = magic_convert(query_set, key_name='run', value_name='count') query_set = TestCaseRun.objects.filter( **run_filters).values('run').annotate( count=Count('case')).order_by('run') cases_subtotal = magic_convert(query_set, key_name='run', value_name='count') for run in searched_runs: run_id = run.pk cases_count = cases_subtotal.get(run_id, 0) if cases_count: failure_percent = failure_subtotal.get( run_id, 0) * 1.0 / cases_count * 100 success_percent = success_subtotal.get( run_id, 0) * 1.0 / cases_count * 100 else: failure_percent = success_percent = 0 run.nitrate_stats = { 'cases': cases_count, 'failure_percent': failure_percent, 'success_percent': success_percent, } else: response_data = { 'sEcho': int(request.GET.get('sEcho', 0)), 'iTotalRecords': 0, 'iTotalDisplayRecords': 0, 'querySet': TestRun.objects.none(), } json_data = render_to_string(template_name, response_data, request=request) return HttpResponse(json_data, content_type='application/json')