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)
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))
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))
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))
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))
def test_getBugTarget_source_package(self): distribution = self.factory.makeDistribution(name='fnord') series = self.factory.makeDistroSeries( name='pting', distribution=distribution) package = self.factory.makeSourcePackage( sourcepackagename='snarf', distroseries=series, publish=True) self.assertEqual( package, AffectsEmailCommand.getBugTarget('fnord/pting/snarf'))
def test_getBugTarget_distribution_source_package(self): distribution = self.factory.makeDistribution(name='fnord') series = self.factory.makeDistroSeries(name='pting', distribution=distribution) package = self.factory.makeSourcePackage(sourcepackagename='snarf', distroseries=series, publish=True) dsp = distribution.getSourcePackage(package.name) self.assertEqual(dsp, AffectsEmailCommand.getBugTarget('fnord/snarf'))
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))
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))
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)))
def test__normalizePath_leading_slash(self): self.assertEqual( 'foo/bar', AffectsEmailCommand._normalizePath('/foo/bar'))
def test__splitPath_with_slashes(self): self.assertEqual( ('foo', 'bar/baz'), AffectsEmailCommand._splitPath('foo/bar/baz'))
def test_getBugTarget_distroseries(self): distribution = self.factory.makeDistribution(name='fnord') series = self.factory.makeDistroSeries( name='pting', distribution=distribution) self.assertEqual( series, AffectsEmailCommand.getBugTarget('fnord/pting'))
def test_getBugTarget_distroseries(self): distribution = self.factory.makeDistribution(name='fnord') series = self.factory.makeDistroSeries(name='pting', distribution=distribution) self.assertEqual(series, AffectsEmailCommand.getBugTarget('fnord/pting'))
def test__splitPath_no_slashes(self): self.assertEqual( ('foo', ''), AffectsEmailCommand._splitPath('foo'))
def test_getBugTarget_distribution(self): distribution = self.factory.makeDistribution(name='fnord') self.assertEqual(distribution, AffectsEmailCommand.getBugTarget('fnord'))
def test_getBugTarget_distribution(self): distribution = self.factory.makeDistribution(name='fnord') self.assertEqual( distribution, AffectsEmailCommand.getBugTarget('fnord'))
def test__normalizePath_products(self): self.assertEqual( 'foo/bar', AffectsEmailCommand._normalizePath('/products/foo/bar'))
def test__normalizePath_leading_slash(self): self.assertEqual('foo/bar', AffectsEmailCommand._normalizePath('/foo/bar'))
def test__splitPath_with_slashes(self): self.assertEqual(('foo', 'bar/baz'), AffectsEmailCommand._splitPath('foo/bar/baz'))
def test__normalizePath_distros(self): self.assertEqual( 'foo/bar', AffectsEmailCommand._normalizePath('/distros/foo/bar'))
def test__splitPath_no_slashes(self): self.assertEqual(('foo', ''), AffectsEmailCommand._splitPath('foo'))
def test_getBugTarget_project(self): project = self.factory.makeProduct(name='fnord') self.assertEqual(project, AffectsEmailCommand.getBugTarget('fnord'))
def test_getBugTarget_project_series(self): project = self.factory.makeProduct(name='fnord') series = self.factory.makeProductSeries(name='pting', product=project) self.assertEqual(series, AffectsEmailCommand.getBugTarget('fnord/pting'))
def test_getBugTarget_project_series(self): project = self.factory.makeProduct(name='fnord') series = self.factory.makeProductSeries(name='pting', product=project) self.assertEqual( series, AffectsEmailCommand.getBugTarget('fnord/pting'))