Esempio n. 1
0
    def test(self):
        """Does a basic test of as much of the system as possible."""
        afe_models.Test(name='test1', test_type=0, path='test1',
            experimental=True).save()
        afe_models.Test(name='test2', test_type=0, path='test2',
            experimental=True).save()

        tko_models.Status(status_idx=6, word='GOOD').save()

        job = tko_models.Job(job_idx=1)
        kernel = tko_models.Kernel(kernel_idx=1)
        machine = tko_models.Machine(machine_idx=1)
        success_status = tko_models.Status(status_idx=GOOD_STATUS_IDX)
        fail_status = tko_models.Status(status_idx=FAIL_STATUS_IDX)

        tko_test1 = tko_models.Test(job=job, status=success_status,
                                    kernel=kernel, machine=machine,
                                    test='test1',
                                    started_time=self.datetime(2012, 1, 20))
        tko_test1.save()
        tko_test2 = tko_models.Test(job=job, status=success_status,
                                    kernel=kernel, machine=machine,
                                    test='test2',
                                    started_time=self.datetime(2012, 1, 20))
        tko_test2.save()

        passing_experimental._MAX_DAYS_SINCE_LAST_PASS = 10
        passing_experimental._MIN_DAYS_SINCE_FAILURE = 10

        MockDatetime.today().AndReturn(self.datetime(2012, 1, 21))
        MockDatetime.today().AndReturn(self.datetime(2012, 1, 21))
        reporter1 = reporting.Reporter()
        bug1 = reporting.Bug(
                title=u'test1 should be promoted to non-experimental.',
                summary=mox.IgnoreArg(),
                search_marker=u'PassingExperimental(test1)')
        reporter1.report(bug1).AndReturn((11, 1))
        reporter2 = reporting.Reporter()
        bug2 = reporting.Bug(
                title=u'test2 should be promoted to non-experimental.',
                summary=mox.IgnoreArg(),
                search_marker=u'PassingExperimental(test2)')
        reporter2.report(bug2).AndReturn((11, 1))

        self.mox.ReplayAll()
        passing_experimental.main()
    def test_summary_returned_untouched_if_no_search_maker(self):
        """Test that we just return the summary if we have no search marker."""
        mock_host = phapi_lib.ProjectHostingApiClient(mox.IgnoreArg(),
                                                      mox.IgnoreArg())

        bug = reporting.Bug('title', 'summary', None)

        self.mox.ReplayAll()
        result = reporting.Reporter()._anchor_summary(bug)

        self.assertEqual(result, 'summary')
    def test_append_anchor_to_summary_if_search_marker(self):
        """Test that we add an anchor to the search marker."""
        mock_host = phapi_lib.ProjectHostingApiClient(mox.IgnoreArg(),
                                                      mox.IgnoreArg())

        bug = reporting.Bug('title', 'summary', 'marker')

        self.mox.ReplayAll()
        result = reporting.Reporter()._anchor_summary(bug)

        self.assertEqual(
            result,
            'summary\n\n%smarker\n' % reporting.Reporter._SEARCH_MARKER)
    def testWithSearchMarkerSetToNoneIsNotDeduped(self):
        """Test that we do not dedupe bugs that have no search marker."""

        bug = reporting.Bug('title', 'summary', search_marker=None)

        mock_host = phapi_lib.ProjectHostingApiClient(mox.IgnoreArg(),
                                                      mox.IgnoreArg())
        mock_host.create_issue(mox.IgnoreArg()).AndReturn(
            {'id': self._FAKE_ISSUE_ID})

        self.mox.ReplayAll()
        bug_id, bug_count = reporting.Reporter().report(bug)

        self.assertEqual(bug_id, self._FAKE_ISSUE_ID)
        self.assertEqual(bug_count, 1)
    def testGenericBugCanBeFiled(self):
        """Test that we can use a Bug object to file a bug report."""
        self.mox.StubOutWithMock(reporting.Reporter, 'find_issue_by_marker')

        bug = reporting.Bug('title', 'summary', 'marker')

        reporting.Reporter.find_issue_by_marker(
            mox.IgnoreArg()).AndReturn(None)

        mock_host = phapi_lib.ProjectHostingApiClient(mox.IgnoreArg(),
                                                      mox.IgnoreArg())
        mock_host.create_issue(mox.IgnoreArg()).AndReturn(
            {'id': self._FAKE_ISSUE_ID})

        self.mox.ReplayAll()
        bug_id, bug_count = reporting.Reporter().report(bug)

        self.assertEqual(bug_id, self._FAKE_ISSUE_ID)
        self.assertEqual(bug_count, 1)