def builds(self):
     """See `ISourcePackageRelease`."""
     # Excluding PPA builds may seem like a strange thing to do, but,
     # since Archive.copyPackage can copy packages across archives, a
     # build may well have a different archive to the corresponding
     # sourcepackagerelease.
     return BinaryPackageBuild.select("""
         source_package_release = %s AND
         archive.id = binarypackagebuild.archive AND
         archive.purpose IN %s
         """ % sqlvalues(self.id, MAIN_ARCHIVE_PURPOSES),
                                      orderBy=['-date_created', 'id'],
                                      clauseTables=['Archive'])
 def builds(self):
     """See `ISourcePackageRelease`."""
     # Excluding PPA builds may seem like a strange thing to do, but,
     # since Archive.copyPackage can copy packages across archives, a
     # build may well have a different archive to the corresponding
     # sourcepackagerelease.
     return BinaryPackageBuild.select("""
         source_package_release = %s AND
         archive.id = binarypackagebuild.archive AND
         archive.purpose IN %s
         """ % sqlvalues(self.id, MAIN_ARCHIVE_PURPOSES),
         orderBy=['-date_created', 'id'],
         clauseTables=['Archive'])
    def setUp(self):
        """Setup environment for staged binaries upload via security policy.

        1. Setup queue directory and other basic attributes
        2. Override policy options to get security policy and not send emails
        3. Setup a common UploadProcessor with the overridden options
        4. Store number of build present before issuing any upload
        5. Upload the source package via security policy
        6. Clean log messages.
        7. Commit transaction, so the upload source can be seen.
        """
        super(TestStagedBinaryUploadBase, self).setUp()
        self.options.context = self.policy
        self.options.nomails = self.no_mails
        # Set up the uploadprocessor with appropriate options and logger
        self.uploadprocessor = self.getUploadProcessor(self.layer.txn)
        self.build_uploadprocessor = self.getUploadProcessor(self.layer.txn,
                                                             builds=True)
        self.builds_before_upload = BinaryPackageBuild.select().count()
        self.source_queue = None
        self._uploadSource()
        self.layer.txn.commit()
 def assertBuildsCreated(self, amount):
     """Assert that a given 'amount' of build records was created."""
     builds_count = BinaryPackageBuild.select().count()
     self.assertEqual(self.builds_before_upload + amount, builds_count)