← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/deal-with-no-authorized_size into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/deal-with-no-authorized_size into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #965317 in Launchpad itself: "TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'  on +repository-size page"
  https://bugs.launchpad.net/launchpad/+bug/965317

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/deal-with-no-authorized_size/+merge/124097

Correctly deal with Archive's that have a NULL authorized_size during policySpecificChecks for PPA uploads and on Archive:+repository_size.
-- 
https://code.launchpad.net/~stevenk/launchpad/deal-with-no-authorized_size/+merge/124097
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/deal-with-no-authorized_size into lp:launchpad.
=== modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py	2012-06-26 16:50:00 +0000
+++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py	2012-09-13 04:20:49 +0000
@@ -1250,6 +1250,17 @@
             "if you need more space."]
         self.assertEmail(contents)
 
+    def testPPASizeNoQuota(self):
+        self.name16.archive.authorized_size = None
+        upload_dir = self.queueUpload("bar_1.0-1", "~name16/ubuntu")
+        self.processUpload(self.uploadprocessor, upload_dir)
+        contents = [
+            "Subject: [PPA name16] [ubuntu/breezy] bar 1.0-1 (Accepted)"]
+        self.assertEmail(contents)
+        self.assertEqual(
+            self.uploadprocessor.last_processed_upload.queue_root.status,
+            PackageUploadStatus.DONE)
+
     def testPPASizeQuotaSourceWarning(self):
         """Verify the size quota warning for PPA near size limit.
 

=== modified file 'lib/lp/archiveuploader/uploadpolicy.py'
--- lib/lp/archiveuploader/uploadpolicy.py	2012-08-22 17:06:08 +0000
+++ lib/lp/archiveuploader/uploadpolicy.py	2012-09-13 04:20:49 +0000
@@ -223,6 +223,8 @@
 
         # All value in bytes.
         MEGA = 2 ** 20
+        if not self.archive.authorized_size:
+            return
         limit_size = self.archive.authorized_size * MEGA
         current_size = self.archive.estimated_size
         new_size = current_size + upload_size

=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py	2012-08-19 00:32:32 +0000
+++ lib/lp/soyuz/browser/archive.py	2012-09-13 04:20:49 +0000
@@ -633,14 +633,17 @@
         binary_label = '%s binary %s' % (
             number_of_binaries, package_plural(number_of_binaries))
 
-        # Quota is stored in MiB, convert it to bytes.
-        quota = self.context.authorized_size * (2 ** 20)
         used = self.context.estimated_size
-
-        # Calculate the usage factor and limit it to 100%.
-        used_factor = (float(used) / quota)
-        if used_factor > 1:
-            used_factor = 1
+        if self.context.authorized_size:
+            # Quota is stored in MiB, convert it to bytes.
+            quota = self.context.authorized_size * (2 ** 20)
+            # Calculate the usage factor and limit it to 100%.
+            used_factor = (float(used) / quota)
+            if used_factor > 1:
+                used_factor = 1
+        else:
+            quota = 0
+            used_factor = 0
 
         # Calculate the appropriate CSS class to be used with the usage
         # factor. Highlight it (in red) if usage is over 90% of the quota.

=== modified file 'lib/lp/soyuz/browser/tests/archive-views.txt'
--- lib/lp/soyuz/browser/tests/archive-views.txt	2012-08-17 10:37:13 +0000
+++ lib/lp/soyuz/browser/tests/archive-views.txt	2012-09-13 04:20:49 +0000
@@ -172,6 +172,25 @@
     used_css_class:  green
     used_percentage: 0.92
 
+The authorized_size of a PPA can also be None (IE: no limit.)
+
+    >>> login('foo.bar@xxxxxxxxxxxxx')
+    >>> mark.archive.authorized_size = None
+    >>> login(ANONYMOUS)
+
+    >>> mark_archive_view = create_initialized_view(
+    ...     mark.archive, name="+index")
+    >>> mark_repository_usage = mark_archive_view.repository_usage
+    >>> print_repository_usage(mark_repository_usage)
+    binaries_size:   0
+    binary_label:    1 binary package
+    quota:           0
+    source_label:    1 source package
+    sources_size:    9922683
+    used:            9924731
+    used_css_class:  green
+    used_percentage: 0.00
+
 An ArchiveView provides a batched_sources property that can be used
 to get the current batch of publishing records for an archive:
 


Follow ups