← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~james-w/launchpad/improve-makeDistroArchSeries into lp:launchpad/devel

 

James Westby has proposed merging lp:~james-w/launchpad/improve-makeDistroArchSeries into lp:launchpad/devel with lp:~james-w/launchpad/no-more-sampledata-2 as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


Hi,

A small change around makeDistroArchSeries:

  1. Test the method.
  2. remove an unused attribute that prevents verifyObject from passing.
  3. Have the method create a ProcessorFamily rather than using sampledata, and ensure there is at least one processor in that family.

Thanks,

James

-- 
https://code.launchpad.net/~james-w/launchpad/improve-makeDistroArchSeries/+merge/31910
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/launchpad/improve-makeDistroArchSeries into lp:launchpad/devel.
=== modified file 'lib/lp/soyuz/interfaces/distroarchseries.py'
--- lib/lp/soyuz/interfaces/distroarchseries.py	2010-02-20 02:37:49 +0000
+++ lib/lp/soyuz/interfaces/distroarchseries.py	2010-08-05 23:11:16 +0000
@@ -74,9 +74,6 @@
                           "for building PPA packages."),
             required=False))
 
-    # Joins.
-    packages = Attribute('List of binary packages in this port.')
-
     # Page layouts helpers.
     title = exported(
         TextLine(

=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
--- lib/lp/soyuz/model/distroarchseries.py	2010-06-21 07:26:51 +0000
+++ lib/lp/soyuz/model/distroarchseries.py	2010-08-05 23:11:16 +0000
@@ -62,11 +62,6 @@
     package_count = IntCol(notNull=True, default=DEFAULT)
     supports_virtualized = BoolCol(notNull=False, default=False)
 
-    packages = SQLRelatedJoin('BinaryPackageRelease',
-        joinColumn='distroarchseries',
-        intermediateTable='BinaryPackagePublishing',
-        otherColumn='binarypackagerelease')
-
     def __getitem__(self, name):
         return self.getBinaryPackage(name)
 

=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py	2010-08-05 23:11:14 +0000
+++ lib/lp/testing/factory.py	2010-08-05 23:11:16 +0000
@@ -1726,7 +1726,9 @@
         if distroseries is None:
             distroseries = self.makeDistroRelease()
         if processorfamily is None:
-            processorfamily = ProcessorFamilySet().getByName('powerpc')
+            processorfamily = self.makeProcessorFamily()
+        if not processorfamily.processors:
+            self.makeProcessor(family=processorfamily)
         if owner is None:
             owner = self.makePerson()
         if architecturetag is None:

=== modified file 'lib/lp/testing/tests/test_factory.py'
--- lib/lp/testing/tests/test_factory.py	2010-08-05 23:11:14 +0000
+++ lib/lp/testing/tests/test_factory.py	2010-08-05 23:11:16 +0000
@@ -26,6 +26,7 @@
 from lp.soyuz.interfaces.binarypackagename import IBinaryPackageName
 from lp.soyuz.interfaces.binarypackagerelease import (
     BinaryPackageFileType, IBinaryPackageRelease)
+from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
 from lp.soyuz.interfaces.files import (
     IBinaryPackageFile, ISourcePackageReleaseFile)
 from lp.soyuz.interfaces.publishing import (
@@ -315,6 +316,30 @@
         distribution = self.factory.makeDistribution()
         self.assertThat(distribution.displayname, StartsWith("Distribution"))
 
+    # makeDistroArchSeries
+    def test_makeDistroArchSeries_returns_proxied_IDistroArchSeries(self):
+        das = self.factory.makeDistroArchSeries()
+        self.assertThat(das, ProvidesAndIsProxied(IDistroArchSeries))
+
+    def test_makeDistroArchSeries_makes_ProcessorFamily(self):
+        das1 = self.factory.makeDistroArchSeries()
+        das2 = self.factory.makeDistroArchSeries()
+        self.assertNotEqual(das1.processorfamily, das2.processorfamily)
+
+    def test_makeDistroArchSeries_uses_processorfamily(self):
+        family = self.factory.makeProcessorFamily()
+        das = self.factory.makeDistroArchSeries(processorfamily=family)
+        self.assertEqual(family, das.processorfamily)
+
+    def test_makeDistroArchSeries_has_a_processor(self):
+        das = self.factory.makeDistroArchSeries()
+        self.assertNotEqual([], das.processorfamily.processors)
+
+    def test_makeDistroArchSeries_makes_a_processor_for_existing_family(self):
+        family = self.factory.makeProcessorFamily()
+        das = self.factory.makeDistroArchSeries(processorfamily=family)
+        self.assertNotEqual([], das.processorfamily.processors)
+
     # makeDistroRelease
     def test_makeDistroRelease_returns_IDistroSeries(self):
         distroseries = self.factory.makeDistroRelease()