← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~sinzui/launchpad/commercial-jobs-1 into lp:launchpad

 

Curtis Hovey has proposed merging lp:~sinzui/launchpad/commercial-jobs-1 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1013852 in Launchpad itself: "ProgrammingError permission denied for commercial jobs"
  https://bugs.launchpad.net/launchpad/+bug/1013852

For more details, see:
https://code.launchpad.net/~sinzui/launchpad/commercial-jobs-1/+merge/110911

This branch fixes the two kinds of oops seen in testing on qastaging.
The job cannot send emails to teams because of missing db permissions.
The job assumes every series has branch.

--------------------------------------------------------------------

RULES

    Pre-implementation: no one
    * Update the tests to include a series without branch, check for a branch
      in the code before accessing the private attr.
    * Update the tests to include a project owned by a team, add permission
      to the needed tables to make th test pass.


QA

    Ask a webops to run the script on qastaging.
    * ./cronscripts/process-job-source.py ICommercialExpiredJobSource
    * Verify there are no oopses. There were 17 in the first test. There
      should be a message that 17 CommercialExpiredJob ran.


LINT

    database/schema/security.cfg
    lib/lp/registry/model/productjob.py
    lib/lp/registry/tests/test_productjob.py


TEST

    ./bin/test -vv lp.registry.tests.test_productjob


IMPLEMENTATION

Added the mising db permissions for the product-job user. Update the job
code to look for a branch on a series first.
    database/schema/security.cfg
    lib/lp/registry/model/productjob.py
    lib/lp/registry/tests/test_productjob.py
-- 
https://code.launchpad.net/~sinzui/launchpad/commercial-jobs-1/+merge/110911
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/commercial-jobs-1 into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2012-06-18 02:56:14 +0000
+++ database/schema/security.cfg	2012-06-18 21:08:18 +0000
@@ -2386,4 +2386,6 @@
 public.productseries                    = SELECT, UPDATE
 public.productjob                       = SELECT, INSERT
 public.sourcepackagename                = SELECT
+public.teammembership                   = SELECT
+public.teamparticipation                = SELECT
 type=user

=== modified file 'lib/lp/registry/model/productjob.py'
--- lib/lp/registry/model/productjob.py	2012-06-14 16:49:03 +0000
+++ lib/lp/registry/model/productjob.py	2012-06-18 21:08:18 +0000
@@ -470,7 +470,7 @@
         else:
             removeSecurityProxy(self.product).private_bugs = False
             for series in self.product.series:
-                if series.branch.private:
+                if series.branch is not None and series.branch.private:
                     removeSecurityProxy(series).branch = None
             self.product.commercial_subscription.delete()
 

=== modified file 'lib/lp/registry/tests/test_productjob.py'
--- lib/lp/registry/tests/test_productjob.py	2012-06-14 16:49:03 +0000
+++ lib/lp/registry/tests/test_productjob.py	2012-06-18 21:08:18 +0000
@@ -574,9 +574,12 @@
             product.development_focus.branch = private_branch
         self.expire_commercial_subscription(product)
         job = self.JOB_CLASS.create(product, reviewer)
-        # Create a proprietary project which will have different DB relations.
+        # Create a proprietary project owned by a team which will have
+        # different DB relations.
+        team = self.factory.makeTeam(
+            subscription_policy=TeamSubscriptionPolicy.RESTRICTED)
         proprietary_product = self.factory.makeProduct(
-            licenses=[License.OTHER_PROPRIETARY])
+            owner=team, licenses=[License.OTHER_PROPRIETARY])
         self.expire_commercial_subscription(proprietary_product)
         proprietary_job = self.JOB_CLASS.create(proprietary_product, reviewer)
         transaction.commit()
@@ -712,6 +715,8 @@
             public_series.branch = public_branch
             private_series = product.newSeries(
                 product.owner, 'special', 'testing', branch=private_branch)
+            # Verify that branchless series do not raise an error.
+            product.newSeries(product.owner, 'unused', 'no branch')
         self.expire_commercial_subscription(product)
         job = CommercialExpiredJob.create(product, reviewer)
         job._deactivateCommercialFeatures()


Follow ups