113
113
from lp.blueprints.interfaces.specification import ISpecificationSet
114
114
from lp.blueprints.interfaces.sprint import ISprintSet
115
from lp.bugs.adapters.bugchange import BugTaskStatusChange
115
116
from lp.bugs.interfaces.bug import (
1706
def makeBugTask(self, bug=None, target=None, owner=None, publish=True):
1707
def makeBugTask(self, bug=None, target=None, owner=None, publish=True,
1707
1709
"""Create and return a bug task.
1709
1711
If the bug is already targeted to the given target, the existing
1713
1715
one will be created.
1714
1716
:param target: The `IBugTarget`, to which the bug will be
1718
:param owner: The `IPerson` who will own the new BugTask.
1719
:param publish: If `target` is an `ISourcePackage`
1720
or `IDistributionSourcePackage`, should a
1721
SourcePackagePublishingHistory entry be made for the
1723
:param date_created: The date on which the BugTask was created.
1717
1725
if bug is None:
1718
1726
bug = self.makeBug()
1749
1757
if prerequisite is None:
1750
1758
self.makeBugTask(bug, prerequisite_target, publish=publish)
1752
return removeSecurityProxy(bug).addTask(owner, target)
1760
task = removeSecurityProxy(bug).addTask(owner, target)
1761
if date_created is not None:
1762
task.datecreated = date_created
1754
1765
def makeBugNomination(self, bug=None, target=None):
1755
1766
"""Create and return a BugNomination.
4261
4272
target_distroseries, target_pocket,
4262
4273
package_version=package_version, requester=requester)
4276
self, bug_age=365, number_of_tasks=100, number_of_comments=100):
4277
"""Create a new `Bug` with lots of tasks and comments."""
4280
date_created=datetime.now(UTC) - timedelta(days=days))
4281
for i in range(number_of_tasks):
4283
current_date = datetime.now(UTC) - timedelta(days=days)
4284
task = self.makeBugTask(bug=bug, date_created=current_date)
4285
change = BugTaskStatusChange(
4286
bug_task=task, when=current_date,
4287
person=bug.owner, what_changed='status',
4288
old_value=BugTaskStatus.NEW, new_value=BugTaskStatus.TRIAGED)
4289
bug.addChange(change)
4290
msg = self.makeMessage(
4291
content="Comment on day %i" % days, datecreated=current_date)
4292
bug.linkMessage(msg)
4293
for i in range(number_of_comments):
4295
current_date = datetime.now(UTC) - timedelta(days=days)
4296
msg = self.makeMessage(
4297
content="Comment on day %i" % days, datecreated=current_date)
4298
bug.linkMessage(msg)
4265
4302
# Some factory methods return simple Python types. We don't add
4266
4303
# security wrappers for them, as well as for objects created by