Example #1
0
    def test_get_bug_ids(self):
        bug_ids = get_run_bug_ids(self.test_run.pk)

        self.assertEqual(3, len(bug_ids))

        # Convert result to dict in order to compare the equivalence easily

        expected = {
            '123456': self.bugzilla.url_reg_exp % '123456',
            '100000': self.bugzilla.url_reg_exp % '100000',
            '100001': self.bugzilla.url_reg_exp % '100001',
        }
        self.assertEqual(expected, dict(bug_ids))
Example #2
0
    def test_get_bug_ids(self):
        bug_ids = get_run_bug_ids(self.test_run.pk)

        self.assertEqual(3, len(bug_ids))

        # Convert result to list in order to compare more easily
        received_bugs = []
        for bug in bug_ids:
            received_bugs.append(bug['bug_system__url_reg_exp'] % bug['bug_id'])

        self.assertIn(self.bugzilla.url_reg_exp % '123456', received_bugs)
        self.assertIn(self.bugzilla.url_reg_exp % '100000', received_bugs)
        self.assertIn(self.bugzilla.url_reg_exp % '100001', received_bugs)
Example #3
0
File: views.py Project: fmca/Kiwi
    def get_context_data(self, **kwargs):
        """Generate report for specific TestRun

        There are four data source to generate this report.
        1. TestRun
        2. Test case runs included in the TestRun
        3. Comments associated with each test case run
        4. Statistics
        5. bugs
        """
        run = TestRun.objects.select_related('manager',
                                             'plan').get(pk=self.run_id)

        case_runs = TestCaseRun.objects.filter(run=run).select_related(
            'case_run_status', 'case',
            'tested_by').only('close_date', 'case_run_status__name',
                              'case__category__name', 'case__summary',
                              'case__is_automated',
                              'case__is_automated_proposed',
                              'tested_by__username')
        mode_stats = self.stats_mode_case_runs(case_runs)
        summary_stats = self.get_summary_stats(case_runs)

        test_case_run_bugs = []
        bug_system_types = {}
        for _bug in get_run_bug_ids(self.run_id):
            # format the bug URLs based on DB settings
            test_case_run_bugs.append((
                _bug['bug_id'],
                _bug['bug_system__url_reg_exp'] % _bug['bug_id'],
            ))
            # find out all unique bug tracking systems which were used to record
            # bugs in this particular test run. we use this data for reporting
            if _bug['bug_system'] not in bug_system_types:
                # store a tracker type object for producing the report URL
                tracker_class = IssueTrackerType.from_name(
                    _bug['bug_system__tracker_type'])
                bug_system = BugSystem.objects.get(pk=_bug['bug_system'])
                tracker = tracker_class(bug_system)
                bug_system_types[_bug['bug_system']] = (tracker, [])

            # store the list of bugs as well
            bug_system_types[_bug['bug_system']][1].append(_bug['bug_id'])

        # list of URLs which opens all bugs reported to every different
        # issue tracker used in this test run
        report_urls = []
        for (issue_tracker, ids) in bug_system_types.values():
            report_url = issue_tracker.all_issues_link(ids)
            # if IT doesn't support this feature or report url is not configured
            # the above method will return None
            if report_url:
                report_urls.append((issue_tracker.tracker.name, report_url))

        case_run_bugs = self.get_case_runs_bugs(run.pk)
        comments = self.get_case_runs_comments(run.pk)

        for case_run in case_runs:
            case_run.bugs = case_run_bugs.get(case_run.pk, ())
            case_run.user_comments = comments.get(case_run.pk, [])

        context = super().get_context_data(**kwargs)
        context.update({
            'test_run': run,
            'test_case_runs': case_runs,
            'test_case_runs_count': len(case_runs),
            'test_case_run_bugs': test_case_run_bugs,
            'mode_stats': mode_stats,
            'summary_stats': summary_stats,
            'report_urls': report_urls,
        })

        return context
Example #4
0
 def test_get_bug_ids_when_no_bug_is_added(self):
     bug_ids = get_run_bug_ids(self.test_run_1.pk)
     self.assertEqual(0, len(bug_ids))
Example #5
0
 def test_get_bug_ids_when_no_bug_is_added(self):
     bug_ids = get_run_bug_ids(self.test_run_1.pk)
     self.assertEqual(0, len(bug_ids))