Example #1
0
 def test_private_bug(self):
     # Closing private bugs is not a problem.
     self.bug.transitionToInformationType(
         InformationType.USERDATA, self.distro.owner)
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id])
     self.assertEqual(BugTaskStatus.FIXRELEASED, self.bugtasks[0].status)
 def test_private_bug(self):
     # Closing private bugs is not a problem.
     self.bug.transitionToInformationType(
         InformationType.USERDATA, self.distro.owner)
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id])
     self.assertEqual(BugTaskStatus.FIXRELEASED, self.bugtasks[0].status)
Example #3
0
 def test_ignore_unknown_bug_ids(self):
     # Unknown bug IDs are ignored, and no message is added.
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id + 1])
     for bugtask in self.bugtasks:
         self.assertEqual(BugTaskStatus.NEW, bugtask.status)
     self.assertEqual(1, self.bug.messages.count())
 def test_ignore_unknown_bug_ids(self):
     # Unknown bug IDs are ignored, and no message is added.
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id + 1])
     for bugtask in self.bugtasks:
         self.assertEqual(BugTaskStatus.NEW, bugtask.status)
     self.assertEqual(1, self.bug.messages.count())
Example #5
0
 def test_correct_tasks_with_distroseries(self):
     # Close the task for the correct source package name and the given
     # series.
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id])
     self.assertEqual(BugTaskStatus.FIXRELEASED, self.bugtasks[0].status)
     for i in (1, 2, 3):
         self.assertEqual(BugTaskStatus.NEW, self.bugtasks[i].status)
 def test_correct_tasks_with_distroseries(self):
     # Close the task for the correct source package name and the given
     # series.
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id])
     self.assertEqual(BugTaskStatus.FIXRELEASED, self.bugtasks[0].status)
     for i in (1, 2, 3):
         self.assertEqual(BugTaskStatus.NEW, self.bugtasks[i].status)
Example #7
0
 def test_correct_message(self):
     # When closing a bug, a reasonable message is added.
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id])
     self.assertEqual(2, self.bug.messages.count())
     self.assertEqual(
         "This bug was fixed in the package %s"
         "\n\n---------------\nchangelog" % self.sprs[0].title,
         self.bug.messages[1].text_contents)
 def test_correct_message(self):
     # When closing a bug, a reasonable message is added.
     close_bug_ids_for_sourcepackagerelease(
         self.series[0], self.sprs[0], [self.bug.id])
     self.assertEqual(2, self.bug.messages.count())
     self.assertEqual(
         "This bug was fixed in the package %s"
         "\n\n---------------\nchangelog" % self.sprs[0].title,
         self.bug.messages[1].text_contents)
Example #9
0
def close_bugs_for_sourcepackagerelease(distroseries,
                                        source_release,
                                        changesfile_object,
                                        since_version=None):
    """Close bugs for a given source.

    Given an `IDistroSeries`, an `ISourcePackageRelease`, and a
    corresponding changesfile object, close bugs mentioned in the
    changesfile in the context of the source.

    If changesfile_object is None and since_version is supplied,
    close all the bugs in changelog entries made after that version and up
    to and including the source_release's version.  It does this by parsing
    the changelog on the sourcepackagerelease.  This could be extended in
    the future to deal with the changes file as well but there is no
    requirement to do so right now.
    """
    if since_version and source_release.changelog:
        bug_ids_to_close = get_bug_ids_from_changelog_entry(
            source_release, since_version=since_version)
    elif changesfile_object:
        bug_ids_to_close = get_bug_ids_from_changes_file(changesfile_object)
    else:
        return

    # No bugs to be closed by this upload, move on.
    if not bug_ids_to_close:
        return

    if getSecurityPolicy() == LaunchpadPermissiveSecurityPolicy:
        # We're already running in a script, so we can just close the bugs
        # directly.
        close_bug_ids_for_sourcepackagerelease(distroseries, source_release,
                                               bug_ids_to_close)
    else:
        job_source = getUtility(IProcessAcceptedBugsJobSource)
        job_source.create(distroseries, source_release, bug_ids_to_close)
def close_bugs_for_sourcepackagerelease(distroseries, source_release,
                                        changesfile_object,
                                        since_version=None):
    """Close bugs for a given source.

    Given an `IDistroSeries`, an `ISourcePackageRelease`, and a
    corresponding changesfile object, close bugs mentioned in the
    changesfile in the context of the source.

    If changesfile_object is None and since_version is supplied,
    close all the bugs in changelog entries made after that version and up
    to and including the source_release's version.  It does this by parsing
    the changelog on the sourcepackagerelease.  This could be extended in
    the future to deal with the changes file as well but there is no
    requirement to do so right now.
    """
    if since_version and source_release.changelog:
        bug_ids_to_close = get_bug_ids_from_changelog_entry(
            source_release, since_version=since_version)
    elif changesfile_object:
        bug_ids_to_close = get_bug_ids_from_changes_file(changesfile_object)
    else:
        return

    # No bugs to be closed by this upload, move on.
    if not bug_ids_to_close:
        return

    if getSecurityPolicy() == LaunchpadPermissiveSecurityPolicy:
        # We're already running in a script, so we can just close the bugs
        # directly.
        close_bug_ids_for_sourcepackagerelease(
            distroseries, source_release, bug_ids_to_close)
    else:
        job_source = getUtility(IProcessAcceptedBugsJobSource)
        job_source.create(distroseries, source_release, bug_ids_to_close)