> === modified file 'lib/lp/registry/interfaces/distributionsourcepackage.py'
> --- lib/lp/registry/interfaces/distributionsourcepackage.py 2010-02-12 13:39:56 +0000
> +++ lib/lp/registry/interfaces/distributionsourcepackage.py 2010-06-04 18:48:29 +0000
> @@ -78,6 +78,22 @@
> "no such package -- this occurs when there is no current series for "
> "the distribution.")
>
> + total_bug_heat = Attribute(
> + "Sum of the bug heat for all the bugs matching the distribution "
> + "and sourcepackagename of the IDistributionSourcePackage.")
> +
> + max_bug_heat = Attribute(
> + "Maximum bug heat for a single bug matching the distribution "
> + "and sourcepackagename of the IDistributionSourcePackage.")
> +
> + bug_count = Attribute(
> + "Number of bugs matching the distribution and sourcepackagename "
> + "of the IDistributionSourcePackage.")
> +
> + po_message_count = Attribute(
> + "Number of translations matching the distribution and "
> + "sourcepackagename of the IDistributionSourcePackage.")
> +
> def getReleasesAndPublishingHistory():
> """Return a list of all releases of this source package in this
> distribution and their correspodning publishing history.
Typo: corresponding (not yours)
> === modified file 'lib/lp/registry/model/distributionsourcepackage.py'
> --- lib/lp/registry/model/distributionsourcepackage.py 2010-03-19 11:13:00 +0000
> +++ lib/lp/registry/model/distributionsourcepackage.py 2010-06-04 18:48:29 +0000
> @@ -54,6 +59,40 @@
> CustomLanguageCode, HasCustomLanguageCodesMixin)
>
>
> +class DistributionSourcePackageProperty:
> + def __init__(self, attrname):
> + self.attrname = attrname
> +
> + def __get__(self, obj, class_):
> + return getattr(obj._self_in_database, self.attrname, None)
> +
> + def __set__(self, obj, value):
> + if obj._self_in_database is None:
> + # Log an oops without raising an error.
> + exception = AssertionError(
> + "DistributionSourcePackage record should have been created "
> + "earlier in the database for distro=%s, sourcepackagename=%s"
> + % (obj.distribution.name, obj.sourcepackagename.name))
Hi Edwin,
This change looks great. I marked a couple of niggly bits but that's
all.
--bac
> === added file 'database/ schema/ patch-2207- 56-0.sql' schema/ patch-2207- 56-0.sql 1970-01-01 00:00:00 +0000 schema/ patch-2207- 56-0.sql 2010-06-04 18:48:29 +0000
> --- database/
> +++ database/
> @@ -0,0 +1,24 @@
> +-- Copyright 2009 Canonical Ltd. This software is licensed under the
2010
(The contents of the patch are left for a db review.)
> === modified file 'lib/lp/ bugs/tests/ test_bugheat. py' bugs/tests/ test_bugheat. py 2010-06-01 09:21:32 +0000 bugs/tests/ test_bugheat. py 2010-06-04 18:48:29 +0000
> --- lib/lp/
> +++ lib/lp/
> @@ -7,8 +7,11 @@
Edwin this test is really readable and easy to follow. Good job.
> import unittest ssLayer Factory makeDistributio nSourcePackage( ) rcePackageNullB ugHeatCacheTest ( tory): ssLayer tory.setUp( self) makeDistributio nSourcePackage( ) max_bug_ heat(self) : l(None, self.target. max_bug_ heat) total_bug_ heat(self) : l(None, self.target. total_bug_ heat) bug_count( self): l(None, self.target. bug_count) rcePackageZeroR ecalculateBugHe atCacheTest( tory): ssLayer tory.setUp( self) makeDistributio nSourcePackage( ) recalculateBugH eatCache( ) max_bug_ heat(self) : max_bug_ heat) total_bug_ heat(self) : total_bug_ heat) bug_count( self): bug_count) rcePackageMulti pleBugsRecalcul ateBugHeatCache Test( tory): ssLayer tory.setUp( self) makeDistributio nSourcePackage( ) makeBugTask( target= self.target) makeBugTask( target= self.target) recalculateBugH eatCache( ) should be called bug_heat( self): l(self. max_heat, self.target. max_bug_ heat) bug_heat( self): l(self. total_heat, self.target. total_bug_ heat) total_bug_ heat > self.target. max_bug_ heat, count(self) : bug_count) xHeatByTargetTe st( Base, unittest.TestCase):
>
> +from storm.store import Store
> +
> from canonical.testing import LaunchpadZopele
>
> +from lp.testing import TestCaseWithFactory
> from lp.testing.factory import LaunchpadObject
>
>
> @@ -58,6 +61,85 @@
> def setUp(self):
> self.target = self.factory.
>
> +class DistributionSou
> + TestCaseWithFac
> + """Ensure distro source package cache values start at None."""
> +
> + layer = LaunchpadZopele
> +
> + def setUp(self):
> + TestCaseWithFac
> + self.target = self.factory.
> +
> + def test_null_
> + self.assertEqua
> +
> + def test_null_
> + self.assertEqua
> +
> + def test_null_
> + self.assertEqua
> +
> +
> +class DistributionSou
> + TestCaseWithFac
> + """Ensure distro source package cache values become zero properly."""
> +
> + layer = LaunchpadZopele
> +
> + def setUp(self):
> + TestCaseWithFac
> + self.target = self.factory.
> + self.target.
> +
> + def test_zero_
> + self.assertEqual(0, self.target.
> +
> + def test_zero_
> + self.assertEqual(0, self.target.
> +
> + def test_zero_
> + self.assertEqual(0, self.target.
> +
> +
> +class DistributionSou
> + TestCaseWithFac
> + """Ensure distro source package cache values are set properly."""
> +
> + layer = LaunchpadZopele
> +
> + def setUp(self):
> + TestCaseWithFac
> + self.target = self.factory.
> + self.bugtask1 = self.factory.
> + self.bugtask2 = self.factory.
> + # Bug heat gets calculated by complicated rules in a db
> + # stored procedure. We will override them here to avoid
> + # testing inconsitencies if those values are calculated
> + # differently in the future.
> + # target.
> + # automatically by bug.setHeat().
> + bug1 = self.bugtask1.bug
> + bug2 = self.bugtask2.bug
> + bug1.setHeat(7)
> + bug2.setHeat(19)
> + Store.of(bug1).flush()
> + self.max_heat = max(bug1.heat, bug2.heat)
> + self.total_heat = sum([bug1.heat, bug2.heat])
> +
> + def test_max_
> + self.assertEqua
> +
> + def test_total_
> + self.assertEqua
> + self.failUnless(
> + self.target.
> + "Total bug heat should be more than the max bug heat, "
> + "since we know that multiple bugs have nonzero heat.")
> +
> + def test_bug_
> + self.assertEqual(2, self.target.
> +
>
> class SourcePackageMa
> MaxHeatByTarget
> === modified file 'lib/lp/ registry/ interfaces/ distributionsou rcepackage. py' registry/ interfaces/ distributionsou rcepackage. py 2010-02-12 13:39:56 +0000 registry/ interfaces/ distributionsou rcepackage. py 2010-06-04 18:48:29 +0000 urcePackage. ") urcePackage. ") urcePackage. ") urcePackage. ") ublishingHistor y():
> --- lib/lp/
> +++ lib/lp/
> @@ -78,6 +78,22 @@
> "no such package -- this occurs when there is no current series for "
> "the distribution.")
>
> + total_bug_heat = Attribute(
> + "Sum of the bug heat for all the bugs matching the distribution "
> + "and sourcepackagename of the IDistributionSo
> +
> + max_bug_heat = Attribute(
> + "Maximum bug heat for a single bug matching the distribution "
> + "and sourcepackagename of the IDistributionSo
> +
> + bug_count = Attribute(
> + "Number of bugs matching the distribution and sourcepackagename "
> + "of the IDistributionSo
> +
> + po_message_count = Attribute(
> + "Number of translations matching the distribution and "
> + "sourcepackagename of the IDistributionSo
> +
> def getReleasesAndP
> """Return a list of all releases of this source package in this
> distribution and their correspodning publishing history.
Typo: corresponding (not yours)
> === modified file 'lib/lp/ registry/ model/distribut ionsourcepackag e.py' registry/ model/distribut ionsourcepackag e.py 2010-03-19 11:13:00 +0000 registry/ model/distribut ionsourcepackag e.py 2010-06-04 18:48:29 +0000 geCodesMixin) rcePackagePrope rty: obj._self_ in_database, self.attrname, None) in_database is None: urcePackage record should have been created " me=%s" on.name, obj.sourcepacka gename. name))
> --- lib/lp/
> +++ lib/lp/
> @@ -54,6 +59,40 @@
> CustomLanguageCode, HasCustomLangua
>
>
> +class DistributionSou
> + def __init__(self, attrname):
> + self.attrname = attrname
> +
> + def __get__(self, obj, class_):
> + return getattr(
> +
> + def __set__(self, obj, value):
> + if obj._self_
> + # Log an oops without raising an error.
> + exception = AssertionError(
> + "DistributionSo
> + "earlier in the database for distro=%s, sourcepackagena
> + % (obj.distributi
Will this generate an OOPS report?
> + getUtility( IErrorReporting Utility) .raising( __class_ _, exception, None)) obj.distributio n).find( blishingHistory , blishingHistory .distroseriesID == distributionID == obj.distributio n.id, blishingHistory .sourcepackager eleaseID == lease.id, lease.sourcepac kagenameID == gename. id by(Desc( SourcePackagePu blishingHistory .id)).first( ) ISectionSet) ['misc' ] obj.distributio n, obj.sourcepacka gename, section) obj._self_ in_database, self.attrname, value) rcePackage( BugTargetBase, estionTargetMix in, riptionTargetMi xin, urcePackage, IHasBugHeat, IHasCustomLangu ageCodes, guidelines = DistributionSou rcePackagePrope rty( guidelines' ) rcePackagePrope rty('max_ bug_heat' ) rcePackagePrope rty('total_ bug_heat' ) rcePackagePrope rty('bug_ count') rcePackagePrope rty('po_ message_ count') rcePackagePrope rty('section' ) agename = sourcepackagename
> + (exception.
> + spph = Store.of(
> + SourcePackagePu
> + SourcePackagePu
> + DistroSeries.id,
> + DistroSeries.
> + SourcePackagePu
> + SourcePackageRe
> + SourcePackageRe
> + obj.sourcepacka
> + ).order_
> + if spph is None:
> + section = getUtility(
> + else:
> + section = spph.section
> + obj._new(
> + setattr(
> +
> +
> class DistributionSou
> SourcePackageQu
> StructuralSubsc
> @@ -72,6 +111,14 @@
> IDistributionSo
> IQuestionTarget)
>
> + bug_reporting_
> + 'bug_reporting_
> + max_bug_heat = DistributionSou
> + total_bug_heat = DistributionSou
> + bug_count = DistributionSou
> + po_message_count = DistributionSou
> + section = DistributionSou
> +
> def __init__(self, distribution, sourcepackagename):
> self.distribution = distribution
> self.sourcepack