1
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
6
from textwrap import dedent
7
from zope.security.proxy import removeSecurityProxy
9
from canonical.testing.layers import LaunchpadZopelessLayer
10
from lp.bugs.interfaces.bugtask import BugTaskStatus
11
from lp.soyuz.scripts.processaccepted import (
12
close_bugs_for_sourcepackagerelease,
14
from lp.testing import TestCaseWithFactory
17
class TestClosingBugs(TestCaseWithFactory):
18
"""Test the various bug closing methods in processaccepted.py.
20
Tests are currently spread around the codebase; this is an attempt to
21
start a unification in a single file and those other tests need
24
* lp/soyuz/scripts/tests/test_queue.py
25
* lib/lp/soyuz/doc/closing-bugs-from-changelogs.txt
26
* lib/lp/archiveuploader/tests/nascentupload-closing-bugs.txt
28
layer = LaunchpadZopelessLayer
30
def test_close_bugs_for_sourcepackagerelease_with_no_changes_file(self):
31
# If there's no changes file it should read the changelog_entry on
32
# the sourcepackagerelease.
34
spr = self.factory.makeSourcePackageRelease(changelog_entry="blah")
36
# Make 4 bugs and corresponding bugtasks and put them in an array
40
bug = self.factory.makeBug()
41
bugtask = self.factory.makeBugTask(
42
target=spr.sourcepackage, bug=bug)
43
bugs.append((bug, bugtask))
45
unfixed_bug = self.factory.makeBug()
46
unfixed_task = self.factory.makeBugTask(
47
target=spr.sourcepackage, bug=unfixed_bug)
49
# Make a changelog entry for a package which contains the IDs of
50
# the 5 bugs separated across 2 releases.
52
foo (1.0-3) unstable; urgency=low
57
-- Foo Bar <foo@example.com> Tue, 01 Jan 1970 01:50:41 +0000
59
foo (1.0-2) unstable; urgency=low
63
-- Foo Bar <foo@example.com> Tue, 01 Jan 1970 01:50:41 +0000
65
foo (1.0-1) unstable; urgency=low
69
-- Foo Bar <foo@example.com> Tue, 01 Jan 1970 01:50:41 +0000
79
lfa = self.factory.makeLibraryFileAlias(content=changelog)
81
removeSecurityProxy(spr).changelog = lfa
82
self.layer.txn.commit()
84
# Call the method and test it's closed the bugs.
85
close_bugs_for_sourcepackagerelease(spr, changesfile_object=None,
86
since_version="1.0-1")
87
for bug, bugtask in bugs:
88
self.assertEqual(BugTaskStatus.FIXRELEASED, bugtask.status)
90
self.assertEqual(BugTaskStatus.NEW, unfixed_task.status)