Пример #1
0
 def test_execute_bug(self):
     bug = self.factory.makeBug()
     product = self.factory.makeProduct(name='fnord')
     login_person(bug.bugtasks[0].target.owner)
     command = AffectsEmailCommand('affects', ['fnord'])
     bugtask, bugtask_event, bug_event = command.execute(bug, None)
     self.assertEqual(bug, bugtask.bug)
     self.assertEqual(product, bugtask.target)
     self.assertTrue(IObjectCreatedEvent.providedBy(bugtask_event))
     self.assertEqual(None, bug_event)
Пример #2
0
 def test_execute_bug_params_distribution(self):
     user = self.factory.makePerson()
     login_person(user)
     distribution = self.factory.makeDistribution(name='fnord')
     message = self.factory.makeMessage(subject='bug title',
                                        content='borked\n affects fnord')
     command = AffectsEmailCommand('affects', ['fnord'])
     bug_params = CreateBugParams(title='bug title',
                                  msg=message,
                                  owner=user)
     bugtask, bugtask_event, bug_event = command.execute(bug_params, None)
     self.assertEqual(distribution, bugtask.target)
     self.assertEqual('bug title', bugtask.bug.title)
     self.assertTrue(IObjectCreatedEvent.providedBy(bugtask_event))
     self.assertTrue(IObjectCreatedEvent.providedBy(bug_event))
Пример #3
0
 def test_execute_bug_params_productseries(self):
     product = self.factory.makeProduct(name='fnord')
     login_person(product.owner)
     series = self.factory.makeProductSeries(name='pting', product=product)
     message = self.factory.makeMessage(
         subject='bug title', content='borked\n affects fnord/pting')
     command = AffectsEmailCommand('affects', ['fnord/pting'])
     bug_params = CreateBugParams(title='bug title',
                                  msg=message,
                                  owner=product.owner)
     bugtask, bugtask_event, bug_event = command.execute(bug_params, None)
     self.assertEqual(series, bugtask.target)
     self.assertEqual('bug title', bugtask.bug.title)
     self.assertEqual(2, len(bugtask.bug.bugtasks))
     self.assertTrue(IObjectCreatedEvent.providedBy(bugtask_event))
     self.assertTrue(IObjectCreatedEvent.providedBy(bug_event))
Пример #4
0
 def test_execute_bug_params_distroseries_sourcepackage(self):
     distribution = self.factory.makeDistribution(name='fnord')
     login_person(distribution.owner)
     series = self.factory.makeDistroSeries(name='pting',
                                            distribution=distribution)
     package = self.factory.makeSourcePackage(sourcepackagename='snarf',
                                              distroseries=series,
                                              publish=True)
     message = self.factory.makeMessage(
         subject='bug title', content='borked\n affects fnord/pting/snarf')
     command = AffectsEmailCommand('affects', ['fnord/pting/snarf'])
     bug_params = CreateBugParams(title='bug title',
                                  msg=message,
                                  owner=distribution.owner)
     bugtask, bugtask_event, bug_event = command.execute(bug_params, None)
     self.assertEqual(package, bugtask.target)
     self.assertEqual('bug title', bugtask.bug.title)
     self.assertEqual(2, len(bugtask.bug.bugtasks))
     self.assertTrue(IObjectCreatedEvent.providedBy(bugtask_event))
     self.assertTrue(IObjectCreatedEvent.providedBy(bug_event))
Пример #5
0
 def test_execute_bug_cannot_add_task(self):
     # Test that attempts to invalidly add a new bug task results in the
     # expected error message.
     product = self.factory.makeProduct(
         bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
     bug = self.factory.makeBug(
         target=product, information_type=InformationType.PROPRIETARY)
     self.factory.makeProduct(
         name='fnord', bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
     login_celebrity('admin')
     login_person(bug.owner)
     command = AffectsEmailCommand('affects', ['fnord'])
     error = self.assertRaises(EmailProcessingError, command.execute, bug,
                               None)
     reason = ("This proprietary bug already affects %s. "
               "Proprietary bugs cannot affect multiple projects." %
               product.displayname)
     self.assertEqual(
         normalize_whitespace(
             "Bug %s cannot be marked as affecting fnord. %s" %
             (bug.id, reason)), normalize_whitespace(str(error)))